template <typename tmp>
int BinarySearch(const vector<tmp> & v, const tmp & a)
{
int nLow = 0;
int nHigh = v.size() - 1;
while (nLow <= nHigh)
{
int mid = (nLow + nHigh) / 2;
if (v[mid] < a)
{
nLow = mid + 1;
}
else if ( v[mid] > a )
{
nHigh = mid - 1;
}
else
{
return mid;
}
}
return -1;
}