import java.util.*;
public class BinarySearch {
public int getPos(int[] A, int n, int val) {
// write code here
int left = 0, right = n - 1;
boolean exist = false;
while(left <= right){
int mid = (left + right) / 2;
if(A[mid] == val) exist = true;
if(A[mid] >= val){
right = mid - 1;
}else{
left = mid + 1;
}
}
if(exist == false) return -1;
else return right + 1;
}
}