#include <algorithm>
template<class T, class F>
T firstWithProp(T a, T b, F f) {
x:if (a==b) return a;
T m = a + (b-a)/2;
if (f(m)) b=m; else a=m+1;
goto x;
}
int binary_search(const unsigned *a, int n, unsigned x){
return firstWithProp(0, n, [a,x](int n){return a[n]>=x;});
}