#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using Pll = pair; using Pii = pair; constexpr int INF = 1 << 30; constexpr ll LINF = 1LL << 60; constexpr ll MOD = 1000000007; constexpr long double EPS = 1e-10; constexpr int dyx[4][2] = { { 0, 1}, {-1, 0}, {0,-1}, {1, 0} }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; ll sb = 0; cin >> n; vector ab(n); for(int i=0;i> ab[i].first; } for(int i=0;i> ab[i].second; sb += ab[i].second; } if(sb == 0) { cout << "0 0" << endl; return 0; } ll x = 0; ll cnt = 0LL; for(int i=0;i= sb) { x = ab[i].first; break; } } ll ans = 0LL; for(int i=0;i