#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

typedef long long int ll;
using ii= pair<ll,ll>;
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define all(o) (o).begin(),(o).end()
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ld long double
#define eps 0.00000000001
#define mod 1000000007

class prioritize{
    public: bool operator() (ii &p1,ii &p2){
        return p1.F<p2.F;
    }
};

auto start_time= high_resolution_clock::now();
void time()
{
    #ifndef ONLINE_JUDGE
        auto stop_time= high_resolution_clock::now();
        auto duration= duration_cast<milliseconds>(stop_time-start_time);
        cout<<"run time: "<<duration.count()<<" ms"<<"\n";
    #endif
    return;
}

void ojudge()
{
	#ifndef ONLINE_JUDGE
        freopen("input1.txt","r", stdin);
        freopen("output1.txt","w",stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    return;
}



int main()
{
    ojudge();
    

    ll n;
    cin>>n;

    vector<pair<ll,string>> v(n);

    fr(i,0,n){
    	cin>>v[i].S>>v[i].F;
    }

    sort(all(v));

    cout<<v[n-2].S<<"\n";



    time();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)

const ll INF = 1000000000000; //10^12:∞
const ll MOD = 1000000007; //10^9+7:合同式の法

void swap(ll &a, ll &b) {
    ll temp = a;
    a = b;
    b = temp;
}

int main(){
    ll N;
    cin >> N;
    vector<ll> P(N);
    for(ll &p : P) {
        cin >> p;
    }
    vector<ll> ans;
    ll target = 1;
    ll cur = 0;
    for(ll i = 1; i < N; i++) {
        if(P.at(i) == target) {
            for(ll j = i; j >= target; j--) {
                swap(P.at(j), P.at(j - 1));
                ans.push_back(j);
            }
            for(ll j = target - 1; j < i; j++) {
                if(P.at(j) != j + 1) {
                    cout << -1 << endl;
                    return 0;
                }
            }
            target = i + 1;
        }
    }
    // targetがNでない→すべてのswapを使っていない
    if(target != N) {
        cout << -1 << endl;
        return 0;
    }
    for(const ll &elm : ans) {
        cout << elm << endl;
    }
    return 0;
}