#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll N, a, b, s=0, t=0, x=-1; cin >> N; vector> v(N); for (int i=0; i> v[i].first; } for (int i=0; i> b; v[i].second = b; s += b; } sort(v.begin(), v.end()); for (int i=0; i= (s+1)/2){ x = a; break; } } s = 0; for (int i=0; i