#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pld = pair<ld,ld>;
using vi = vector<int>;
using vll = vector<ll>;
using vld = vector<ld>;
#define _GLIBCXX_DEBUG
#define rep(j, m) for (int j = 0; j < (int)(m); j++)
#define rep2(i, l, n) for (int i = l; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
const ld PI = 3.1415926535897932;
const ll MOD = 1000000007;


int main() {
	ll N;
	cin >> N;
	vll W(N);
	rep(i,N) {cin >> W[i];}
	vll V(N);
	ll sum = 0;
	rep(i,N) {
		V[i] = W[i] - i - 1;
		sum += abs(V[i]);
	}
	if (sum == (N - 1)*2) {
		ll flag = 0;
		vll X = V;
		vll Y(N - 1,0);
		rep(i,N - 1) {
			ll a = i;
			while(a >= 0 && X[a] > 0 && X[a + 1] < 0) {
				swap(X[a],X[a + 1]);
				X[a]++;
				X[a + 1]--;
				Y[a]++;
				a--;
			}			
		}
		rep(i,N - 1) {if (X[i] != 0 || Y[i] != 1) {flag++;}}
		if (flag != 0) {cout << -1 << endl;}
		else {
			rep(i,N - 1) {
				ll a = i;
				while(a >= 0 && V[a] > 0 && V[a + 1] < 0) {
					swap(V[a],V[a + 1]);
					V[a]++;
					V[a + 1]--;
					cout << a + 1 << endl;
					a--;
				}
			}
		}
	}
	else {cout << -1 << endl;}

}

#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>

#define REP(i,N) for(int (i)=0;(i)<(N);(i)++)
#define REP2(i,a,N) for(int (i)=(a);(i)<(N);(i)++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#include <iomanip> 
using namespace std;
using ll = long long;
ll gcd(ll x, ll y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}

ll lcm(ll x, ll y) {
    return ll(x / gcd(x, y)) * y;
}

vector< int > divisor(int n) {
    vector< int > ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return ret;
}
template<class T>
auto comp_idx(T& ptr) {
    return [ptr](int l_idx, int r_idx) {
        return ptr[l_idx] < ptr[r_idx];
    };
}
//std::sort(IndA.begin(), IndA.end(), comp_idx(A));

int main() {
    string N;
    cin >> N;
    int index = N.size()-1;
    for (int i = N.size() - 1; i >= 0; i--) {
        if (N[i] == '0') {
            index--;
        }
        else break;
    }
    if (index == 0) {
        cout << "Yes";
        return 0;
    }
    for (int i = 0; i < N.size() / 2; i++) {
        if (N[i] != N[index - i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";


    return 0;
}
