if __name__ == "__main__":
N = int(input())
total = 0
city_dict = {}
for _ in range(N):
city, people = map(int, input().split())
city_dict[city] = people
total += people
sorted_list = sorted(city_dict.items())
tmp = 0
for key, value in sorted_list:
tmp+= value
if tmp >= total/2:
print(key)
break