private static int BinarySearch(ulong[] array, ulong value)
{
int lo = 0;
int hi = array.Length - 1;
while (lo <= hi)
{
int i = (lo + hi) >> 1;
ulong temp = array[i];
if (value == temp) return i;
if (temp < value)
{
lo = i + 1;
}
else
{
hi = i - 1;
}
}
return ~lo;
}