#include <bits/stdc++.h>
using namespace std;
int BinarySearch(vector<int> arr, int key)
{
	int start =0, end = arr.size()-1;
	while(start<=end)
	{
		int mid = start + (end-start)/2;
		
		if(arr[mid]==key)
		{
			return mid;
		}
		else if(key<arr[mid])
		{
			end  = mid-1;
		}
		else
		{
			start = mid+1;
		}
	}
	return -1;
}
int main() {
	// your code goes here
	vector<int> arr = {1,3,4,6,7,8};
	
	cout<<BinarySearch(arr,8)<<endl;
	
	return 0;
}