#include<iostream>
#include<string>
#include<vector>
using std::vector;
using std::string;
using std::cout;
using std::endl;
using std::cin;
int main()
{
vector<int> a{ 1,2,3,4,5,6,7 };
int serch = 4;
auto beg = a.begin(), end = a.end(), mid = a.begin() + (end-beg) / 2;
while (mid != end && *mid != serch)
{
if (serch > *mid)
beg = mid + 1;
else
end = mid - 1;
mid = beg+(end-beg)/2;
}
cout << *mid << endl;
return 0;
}