#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(a, a+n, [x](const unsigned *a){return*a>=x;})-a;
}