#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, score;
  string s;
  char temp[100];
  map<string, int> m;
  vector<pair<string, int> > rounds;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s%d", temp, &score);
    s = temp;
    m[s] += score;
    rounds.push_back(make_pair(s, m[s]));
  }
  int max_score = -1000001;
  for (typeof(m.begin()) it = m.begin(); it != m.end(); ++it) {
    max_score = max(max_score, it->second);
  }
  for (typeof(m.begin()) it = m.begin(); it != m.end(); ++it) {
    if (it->second < max_score) it->second = 1000001;
  }
  string res;
  for (typeof(rounds.begin()) it = rounds.begin(); it != rounds.end(); ++it) {
    if (it->second >= m[it->first]) {
      res = it->first;
      break;
    }
  }
  printf("%s\n", res.c_str());
  return 0;
}
