/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author kant97
 */

#include <iostream>
#include <fstream>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>

#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>

#ifndef CONTESTS_CPP_MY_ALIASES_HPP
#define CONTESTS_CPP_MY_ALIASES_HPP

#include <utility>
#include <cstdint>


#include <limits>

using pii = std::pair<int, int>;
using pll = std::pair<int64_t, int64_t>;
using pli = std::pair<int64_t, int>;
using tiii = std::tuple<int, int, int>;
using ui = uint32_t;
using ll = int64_t;
using ull = uint64_t;
#if __x86_64__ && __GNUG__
using int128 = __int128;
using uint128 = unsigned __int128;
#else
using int128 = ll;
using uint128 = ull;
#endif
using vc = std::vector<char>;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;

#define fori(n) for (int i = 0; (i) < (int) (n); ++i)
#define forj(n) for (int j = 0; (j) < (int) (n); ++j)
#define rofi(n) for (int i = (int) (n); (i) >= 0; --i)
#define rofj(n) for (int j = (int) (n); (j) >= 0; --j)
#define forn(i, n) for(int i = 0; i < (int) (n); ++i)
#define fore(i, l, r) for(int i = (int) (l); i < (int) (r); ++i)
#define sqr(x) ((x)*(x))
#define pow2(x) ((ull)1 << static_cast<uint64_t>(x))
#define div2k(x, k) (static_cast<uint64_t>(x) >> static_cast<uint64_t>(k))
#define div2(x) div2k(x, 1ULL)
#define divUP(a, b) ((a)+(b)-1)/(b)
#define lowest_significant_bit(x) (static_cast<ull>(x) & -static_cast<ull>(x))
#define count_set_bits(x) __builtin_popcountll(static_cast<ull>(x))
#define sz(x) (static_cast<int>((x).size()))
#define is_odd(x) static_cast<bool>(static_cast<uint64_t>(x) & 1ULL)
#define is_even(x) (!(is_odd(x)))
#define have_diff_parity(x, y) static_cast<bool>(is_odd(x) ^ is_odd(y))
#define have_same_parity(x, y) (!(have_diff_parity(x, y)))
#define All(x) (x).begin(), (x).end()
#define ENDL "\n"
#define FOR_ALL_TEST_CASES int MyTestCaseCounter; in >> MyTestCaseCounter; while(MyTestCaseCounter--)

#endif //CONTESTS_CPP_MY_ALIASES_HPP


class AHealthMDeath {

public:

    void solve(std::istream &in, std::ostream &out) {
        int m, h;
        in >> m >> h;
        if (h % m == 0) out << "Yes" << ENDL;
        else out << "No" << ENDL;
    }

    bool _my_clever_check(std::istream &input, std::istream &juryAnswer, std::istream &myAnswer) {
        return false;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    AHealthMDeath solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    fflush(stdout);
    return 0;
}

#include <bits/stdc++.h>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mkpr make_pair
#define fi(i,a,b) for (ll i=a;i<b;i++)
#define vll vector<ll>
#define vch vector<char>
#define vst vector<string>
#define vpll vector<pll>
#define vii vector<int>
#define vvl vector<vector<ll>>
#define all(v) v.begin(),v.end()
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.rbegin(), v.rend())
#define mxe(v) *max_element(all(v))
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define mll map<ll, ll>
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)
#define nl "\n"
#define sp " "
#define sz(x)  (int)x.size()

using namespace std;

double PI = (acos(-1));
ll md = 1000000007;
//ll md = 998244353;
ll pw(ll a, ll b){ll c=1,m=a;while (b){if (b&1)c=(c*m);m=(m*m);b/=2;}return c;}
ll pwmd(ll a, ll b){ll c = 1, m = a;while (b){if (b & 1)c = ((c * m)) % md;m = (m * m) % md;b /= 2;}return c;}
ll modinv(ll n){return pwmd(n, md - 2);}
ll nc2(ll n){return (1ll * n * (n - 1)) / 2;}
bool prime(ll a){for(int i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ceel(ll a,ll b){if(a%b==0) return a/b;else return a/b+1;}


#define MAX_SIZE 10005
void Sieve(vector<int> &primes){bool IsPrime[MAX_SIZE];memset(IsPrime, true, sizeof(IsPrime));
for (int p = 2; p * p < MAX_SIZE; p++){if (IsPrime[p] == true){
            for (int i = p * p; i < MAX_SIZE; i += p)IsPrime[i] = false;}}
    for (int p = 2; p < MAX_SIZE; p++)if (IsPrime[p])primes.push_back(p);}
        


vector<char> sml={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char> cap={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};




void solve(){
    ll n;
    cin>>n;
    ll l[n];
    vll v(n+1);
    fi(i,0,n)cin>>l[i],v[l[i]]=i+1;
    vll vis(n+1,0),q,w;
    //fi(i,1,n+1)cout<<v[i]<<nl;
    fi(i,1,n){
        if(v[i]<=i){
            cout<<-1<<nl;
            return;
        }
        for(ll j=v[i]-1;j>=i;j--){
            q.pb(j);
        }
        w.pb(i);
        fi(j,i-1,v[i]-2)w.pb(l[j]);
        l[v[i]-1]=l[v[i]-2];
        i+=max(0ll,v[i]-i-1);
    }
    ll k=0;
    fi(i,0,n-1){
        if(w[i]==i+1)k++;
    }
    if(k==n-1){
        fi(i,0,n-1)cout<<q[i]<<nl;
    }
    else cout<<-1<<nl;
//fi(i,0,n-1)cout<<q[i]<<nl;
}


int main(){
    //vector<int> primes;
    //Sieve(primes);
    
    fast
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
    }
    return 0;
}




