#include <bits/stdc++.h>
using namespace std;
int main() {
  int r;
  cin >> r;
  vector<pair<string, int>> v;
  set<string> temp;
  map<string, int> m;
  int ma = -1;
  for (int i = 0; i < r; i++) {
    string n;
    int s;
    cin >> n >> s;
    temp.insert(n);
    if (m.find(n) != m.end()) {
      m[n] += s;
    } else
      m[n] = s;
    v.push_back(make_pair(n, m[n]));
  }
  for (auto i : m) {
    ma = max(ma, i.second);
  }
  int i;
  for (i = 0; m[v[i].first] < ma || v[i].second < ma; i++)
    ;
  cout << v[i].first;
  return 0;
}
