#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

bool perm(vi v, int n) {
    vi cnt(n+1);
    for(auto val : v) {
        if(val < 1 or val > n)
            return false;

        cnt[val]++;
        if(cnt[val] > 1)
            return false;
    }

    return true;
}

int main() {
    sws;
    int n, k;
    cin >> n >> k;

    vi v(k);
    forn(i, k)
        scanf("%d", &v[i]);

    bool win = true;
    int val = 1;
    vi foi(n+1, 0);
    stack<int> s;

    int prox = 1;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
                prox++;
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        for(int i = s.top(); i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }

        s.pop();
        ant = val;
    }

    if((int)v.size() < n) {
        for(int i = n; i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }
    }

    if(win) {
        for(auto r : v)
            printf("%d ", r);
        printf("\n");
    }
    else {
        printf("-1\n");
    }

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

int main() {
    int n, k;
    cin >> n >> k;

    vi v(k);
    forn(i, k)
        cin >> v[i];

    bool win = true;
    int val = 1;
    vi foi(n+1, 0);
    stack<int> s;

    int prox = 1;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        int val = s.top();
        s.pop();
        for(int i = val; i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }

        ant = val;

        if(s.size() == 0 and ant != n) {
            s.push(n);
        }
    }

    if(win) {
        for(auto r : v)
            cout << r << " ";
        cout << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

bool perm(vi v, int n) {
    vi cnt(n+1);
    for(auto val : v) {
        if(val < 1 or val > n)
            return false;

        cnt[val]++;
        if(cnt[val] > 1)
            return false;
    }

    return true;
}

int main() {
    sws;
    int n, k;
    cin >> n >> k;

    vi v(k);
    forn(i, k)
        cin >> v[i];

    bool win = true;
    int val = 1;
    vi foi(n+1, 0);
    stack<int> s;

    int prox = 1;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
                prox++;
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        for(int i = s.top(); i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }

        s.pop();
        ant = val;
    }

    if(v.size() < n) {
        for(int i = n; i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }
    }

    if(win) {
        assert(perm(v, n));
        for(auto r : v)
            cout << r << " ";
        cout << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

bool perm(vi v, int n) {
    vi cnt(n+1);
    for(auto val : v) {
        if(val < 1 or val > n)
            return false;

        cnt[val]++;
        if(cnt[val] > 1)
            return false;
    }

    return true;
}

int main() {
    sws;
    int n, k;
    cin >> n >> k;

    vi v(k);
    forn(i, k)
        cin >> v[i];

    bool win = true;
    vi foi(n+1, 0);
    stack<int> s;

    int prox = 1;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
                prox++;
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        for(int i = s.top(); i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }

        ant = s.top();
        s.pop();
    }

    if(v.size() < n) {
        for(int i = n; i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }
    }

    if(win) {
        assert(perm(v, n));
        for(auto r : v)
            cout << r << " ";
        cout << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    bool win = true;
    int val = 1;
    vi foi(n+1, 0), res(n), v(k);
    stack<int> s;

    forn(i, k) {
        scanf("%d", &v[i]);
        res[i] = v[i];
    }

    int prox = 1, idx = k;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
                prox++;
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        for(int i = s.top(); i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                res[idx++] = i;
            }
        }

        s.pop();
        ant = val;
    }

    if(ant < n) {
        for(int i = n; i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                res[idx++] = i;
            }
        }
    }

    if(win) {
        for(auto r : res)
            printf("%d ", r);
        printf("\n");
    }
    else {
        printf("-1\n");
    }

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

bool perm(vi v, int n) {
    vi cnt(n+1);
    for(auto val : v) {
        if(val < 1 or val > n)
            return false;

        cnt[val]++;
        if(cnt[val] > 1)
            return false;
    }

    return true;
}

int main() {
    int n, k;
    cin >> n >> k;

    vi v(k);
    forn(i, k)
        cin >> v[i];

    bool win = true;
    int val = 1;
    vi foi(n+1, 0);
    stack<int> s;

    int prox = 1;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        for(int i = s.top(); i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }

        s.pop();
        ant = val;
    }

    if(v.size() < n) {
        for(int i = n; i >= 1; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }
    }

    if(win) {
        assert(perm(v, n));
        for(auto r : v)
            cout << r << " ";
        cout << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

bool perm(vi v, int n) {
    vi cnt(n+1);
    for(auto val : v) {
        if(val < 1 or val > n)
            return false;

        cnt[val]++;
        if(cnt[val] > 1)
            return false;
    }

    return true;
}

int main() {
    int n, k;
    cin >> n >> k;

    vi v(k);
    forn(i, k)
        cin >> v[i];

    bool win = true;
    int val = 1;
    vi foi(n+1, 0);
    stack<int> s;

    int prox = 1;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
                prox++;
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        for(int i = s.top(); i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }

        s.pop();
        ant = val;
    }

    if(v.size() < n) {
        for(int i = n; i >= 1; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }
    }

    if(win) {
        assert(perm(v, n));
        for(auto r : v)
            cout << r << " ";
        cout << endl;
    }
    else {
        cout << -1 << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define teto(a, b) ((a+b-1)/(b))
using namespace std;

const int MAX = 100010;
const int MOD = 1000000007;
const int INF = (int)1e9;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld EPS = 1e-7;

// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define dbg(msg, var) cout << msg << " " << var << endl;
//

bool perm(vi v, int n) {
    vi cnt(n+1);
    for(auto val : v) {
        if(val < 1 or val > n)
            return false;

        cnt[val]++;
        if(cnt[val] > 1)
            return false;
    }

    return true;
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    vi v(k);
    forn(i, k)
        scanf("%d", &v[i]);

    bool win = true;
    int val = 1;
    vi foi(n+1, 0);
    stack<int> s;

    int prox = 1;
    for(int i = 0; i < k and win; i++) {
        if(v[i] == prox) {
            foi[v[i]] = 1;
            prox++;
            while(s.size() and s.top() == prox) {
                s.pop();
                prox++;
            }
        }
        else {
            if(s.size() and s.top() < v[i]) {
                win = false;
            }
            else {
                s.push(v[i]);
                foi[v[i]] = 1;
            }
        }
    }

    int ant = 1;
    while(s.size()) {
        for(int i = s.top(); i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }

        s.pop();
        ant = val;
    }

    if(v.size() < n) {
        for(int i = n; i >= ant; i--) {
            if(!foi[i]) {
                foi[i] = 1;
                v.pb(i);
            }
        }
    }

    if(win) {
        for(auto r : v)
            printf("%d ", r);
        printf("\n");
    }
    else {
        printf("-1\n");
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
stack<int> s;
int a[N], b[N];
bool vis[N];
int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; ++i)
        scanf("%d", &a[i]);
    int maxn = 0;
    for (int i = 1; i <= k; ++i)
    {
        if (a[i] == maxn)
            ++maxn;
        else
            s.push(a[i]);
    }
    int top = 0, pre = maxn;
    while (s.size())
    {
        int tmp = s.top();
        s.pop();
        if (pre > tmp)
            return printf("-1\n"), 0;
        for (int i = tmp - 1; i > pre; --i)
            b[++top] = i;
        maxn = tmp;
        pre = tmp;
    }
    int tmp = n;
    while (++maxn <= n)
        b[++top] = tmp--;
    assert(top == n - k);
    for (int i = 1; i <= k; ++i)
        printf("%d ", a[i]);
    for (int i = 1; i <= n - k; ++i)
        printf("%d ", b[i]);
    printf("\n");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
stack<int> s;
int a[N], b[N];
bool vis[N];
int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; ++i)
        scanf("%d", &a[i]);
    int maxn = 0;
    for (int i = 1; i <= k; ++i)
    {
        if (a[i] - 1 == maxn)
            ++maxn;
        else
            s.push(a[i]);
    }
    int top = 0, pre = maxn;
    while (s.size())
    {
        int tmp = s.top();
        s.pop();
        if (pre > tmp)
            return printf("-1\n"), 0;
        for (int i = tmp - 1; i > pre; --i)
            b[++top] = i;
        maxn = tmp;
        pre = tmp;
    }
    int tmp = n;
    while (++maxn <= n)
        b[++top] = tmp--;
    assert(top == n - k);
    for (int i = 1; i <= k; ++i)
        printf("%d ", a[i]);
    for (int i = 1; i <= n - k; ++i)
        printf("%d ", b[i]);
    printf("\n");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
stack<int> s;
int a[N], b[N];
bool vis[N];
int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= k; ++i)
        scanf("%d", &a[i]);
    int maxn = 0;
    for (int i = 1; i <= k; ++i)
    {
        s.push(a[i]);
        while (s.size() && s.top() - 1 == maxn)
            s.pop(), ++maxn;
    }
    int top = 0, pre = maxn;
    while (s.size())
    {
        int tmp = s.top();
        s.pop();
        if (pre > tmp)
            return printf("-1\n"), 0;
        for (int i = tmp - 1; i > pre; --i)
            b[++top] = i;
        maxn = tmp;
        pre = tmp;
    }
    int tmp = n;
    while (++maxn <= n)
        b[++top] = tmp--;
    assert(top == n - k);
    for (int i = 1; i <= k; ++i)
        printf("%d ", a[i]);
    for (int i = 1; i <= n - k; ++i)
        printf("%d ", b[i]);
    printf("\n");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn = 1e5+10;

int n,k,a[maxn],vis[maxn];
vector<int> vi,ans;

int main(){
    //frein;
    sc(n); sc(k);
    int mx = -1;
    for(int i = 0; i < k; i++) sc(a[i]);
    for(int i = 0; i < k; i++){
        vis[a[i]] = 1;
        mx = max(mx, a[i]);
    }

    for(int i = 0; i < k; i++){
        ans.pb(a[i]);
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0) vi.pb(i);
    }

    int p = lower_bound(ALL(vi), mx) - vi.begin();
    for(int i = p-1; i >= 0; i--){
        ans.pb(vi[i]);
    }
    for(int i = vi.size()-1; i >= p; i--){
        ans.pb(vi[i]);
    }
    for(int i = 1; i < n-1; i++){
        if(ans[i] > ans[i-1] && ans[i] > ans[i+1]){
            printf("-1\n");
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn = 1e5+10;

int n,k,a[maxn],vis[maxn];
vector<int> vi,ans;

int main(){
    //frein;
    sc(n); sc(k);
    int mx = -1;
    for(int i = 0; i < k; i++) sc(a[i]);
    for(int i = 0; i < k; i++){
        vis[a[i]] = 1;
        mx = max(mx, a[i]);
    }

    for(int i = 0; i < k; i++){
        ans.pb(a[i]);
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0) vi.pb(i);
    }

    int p = lower_bound(ALL(vi), mx) - vi.begin();
    for(int i = p-1; i >= 0; i--){
        ans.pb(vi[i]);
    }
    for(int i = vi.size()-1; i >= p; i--){
        ans.pb(vi[i]);
    }
    for(int i = 1; i < n-1; i++){
        if(a[i] > a[i-1] && a[i] > a[i+1]){
            printf("-1\n");
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn = 1e5+10;

int n,k,a[maxn],vis[maxn],sum[maxn],now;
vector<int> vi,ans;

stack<int> stk;
int main(){
    //frein;
    sc(n); sc(k);
    int mx = -1;
    for(int i = 0; i < k; i++) sc(a[i]);
    for(int i = 0; i < k; i++){
        vis[a[i]] = 1;
        mx = max(mx, a[i]);
    }

    for(int i = 0; i < k; i++){
        ans.pb(a[i]);
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0) vi.pb(i);
    }

    int p = lower_bound(ALL(vi), mx) - vi.begin();
    for(int i = p-1; i >= 0; i--){
        ans.pb(vi[i]);
    }
    for(int i = vi.size()-1; i >= p; i--){
        ans.pb(vi[i]);
    }
    now = 1;
    for(int i = 0; i < n; i++){
        while(stk.size() && stk.top() == now){
            now++;
            stk.pop();
        }
        stk.push(a[i]);
    }
    if(now < n){
        printf("-1\n");
        return 0;
    }
    for(int i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn = 1e5+10;

int n,k,a[maxn],vis[maxn],sum[maxn],now;
vector<int> vi,ans;

stack<int> stk;
int main(){
    //frein;
    sc(n); sc(k);
    int mx = -1;
    for(int i = 0; i < k; i++) sc(a[i]);
    for(int i = 0; i < k; i++){
        vis[a[i]] = 1;
        mx = max(mx, a[i]);
    }

    for(int i = 0; i < k; i++){
        ans.pb(a[i]);
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0) vi.pb(i);
    }

    int p = lower_bound(ALL(vi), mx) - vi.begin();
    for(int i = p-1; i >= 0; i--){
        ans.pb(vi[i]);
    }
    for(int i = vi.size()-1; i >= p; i--){
        ans.pb(vi[i]);
    }
    now = 1;
    for(int i = 0; i < n; i++){
        while(stk.size() && stk.top() == now){
            now++;
            stk.pop();
        }
        if(stk.size() && stk.top() < a[i]){
            printf("-1\n");
            return 0;
        }
        stk.push(a[i]);
    }
    for(int i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn = 2e5+10;

int n,k,a[maxn],vis[maxn],sum[maxn],now;
vector<int> ans;

stack<int> stk;
int main(){
    //frein;
    sc(n); sc(k);
    int mx = -1;
    for(int i = 0; i < k; i++) sc(a[i]);
    for(int i = 0; i < k; i++){
        ans.pb(a[i]);
    }
    sort(a, a+k);
    a[k++] = n+1;
    int pre = 1;
    for(int i = 0; i < k; i++){
        for(int j = a[i]-1; j >= pre; j--){
            ans.pb(j);
        }
        pre = a[i]+1;
    }
    now = 1;
    for(int i = 0; i < n; i++){
        while(stk.size() && stk.top() == now){
            now++;
            stk.pop();
        }
        stk.push(ans[i]);
    }
    while(stk.size() && stk.top() == now){
        now++;
        stk.pop();
    }
    if(now < n){
        printf("-1\n");
        return 0;
    }
    for(int i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn = 1e5+10;

int n,k,a[maxn],vis[maxn],sum[maxn],now;
vector<int> ans;

stack<int> stk;
int main(){
    //frein;
    sc(n); sc(k);
    int mx = -1;
    for(int i = 0; i < k; i++) sc(a[i]);
    for(int i = 0; i < k; i++){
        ans.pb(a[i]);
    }
    sort(a, a+k);
    a[k++] = n+1;
    int pre = 1;
    for(int i = 0; i < k; i++){
        for(int j = a[i]-1; j >= pre; j--){
            ans.pb(j);
        }
        pre = a[i]+1;
    }
    now = 1;
    for(int i = 0; i < n; i++){
        while(stk.size() && stk.top() == now){
            now++;
            stk.pop();
        }
        stk.push(ans[i]);
    }
    while(stk.size() && stk.top() == now){
        now++;
        stk.pop();
    }
    if(now < n){
        printf("-1\n");
        return 0;
    }
    for(int i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>
#include <functional>
#include <bitset>

using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define mk make_pair
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)
#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)
#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%d\n", x)
#define fastio ios::sync_with_stdio(0), cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define freout1 freopen("out1.txt", "w", stdout)
#define PI M_PI
#define debug cout<<"???"<<endl
#define mid ((l+r)>>1)
const ll mod = 1000000007;
//const int INF = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-6;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}

const int maxn = 1e5+10;

int n,k,a[maxn],vis[maxn],sum[maxn],now;
vector<int> vi,ans;

stack<int> stk;
int main(){
    //frein;
    sc(n); sc(k);
    int mx = -1;
    for(int i = 0; i < k; i++) sc(a[i]);
    for(int i = 0; i < k; i++){
        vis[a[i]] = 1;
        mx = max(mx, a[i]);
    }

    for(int i = 0; i < k; i++){
        ans.pb(a[i]);
    }
    for(int i = 1; i <= n; i++){
        if(vis[i] == 0) vi.pb(i);
    }

    int p = lower_bound(ALL(vi), mx) - vi.begin();
    for(int i = p-1; i >= 0; i--){
        ans.pb(vi[i]);
    }
    for(int i = vi.size()-1; i >= p; i--){
        ans.pb(vi[i]);
    }
    now = 1;
    for(int i = 0; i < n; i++){
        while(stk.size() && stk.top() == now){
            now++;
            stk.pop();
        }
        stk.push(ans[i]);
    }
    while(stk.size() && stk.top() == now){
        now++;
        stk.pop();
    }
    if(now < n){
        printf("-1\n");
        return 0;
    }
    for(int i = 0; i < n; i++){
        printf("%d ", ans[i]);
    }
    puts("");
    return 0;
}


#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
const double PI = acos(-1.0), EPS = 1e-9;
const int MX=2*1e5+10;
int N, M, k;
int arr[MX];
vector<int> S;
int vis[MX];
int main()
{
    cin>>N>>k;
    for(int i=1; i<=k; i++)
    {
        cin>>arr[i];
        ++vis[arr[i]];
    }
    int cur=1;
    for(int i=1; i<=k; i++)
    {
        S.pb(arr[i]);
        while(S.back() == cur)
        {
            cur++;
            S.pop_back();
        }
    }
    ///  cout<<S.size()<<"\n";
    vector<int> ans;
    int cnt=k, last=k;
    if(cnt == N && S.size()){
        cout<<-1;
        return 0;
    }
    while(cnt != N)
    {
        if(S.empty())
        {
            for(int j=N; j>=cur; j--)
                ans.push_back(j), S.pb(j);
            break;
        }
        int top=S.back();
        for(int j=top-1; j>0; j--)
        {
            if(vis[j] > 0)
            {
                break;
            }
            ++vis[j];
            S.pb(j);
            ++cnt;
            ans.pb(j);
        }
        if(cnt == last) break;
        last=cnt;
        while(S.size() && S.back() == cur) ++cur, S.pop_back();
    }

    while(cur != N && S.size() && S.back() == cur) cur++, S.pop_back();
    if(cur != N || S.size()) cur=0;
    if(ans.size() +k < N || cur == 0)
    {
        cout<<-1;
        return 0;
    }
    for(int i=1; i<=k; i++ ) cout<<arr[i]<< " ";
    for(int i=0; i<ans.size(); i++) cout<<ans[i]<< ' ';
    return 0;

}


#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
const double PI = acos(-1.0), EPS = 1e-9;
const int MX=2*1e5+10;
int N, M, k;
int arr[MX];
vector<int> S;
int vis[MX];
int main()
{
    cin>>N>>k;
    for(int i=1; i<=k; i++)
    {
        cin>>arr[i];
        ++vis[arr[i]];
    }
    int cur=1;
    for(int i=1; i<=k; i++)
    {
        S.pb(arr[i]);
        while(S.back() == cur)
        {
            cur++;
            S.pop_back();
        }
    }
    ///  cout<<S.size()<<"\n";
    vector<int> ans;
    int cnt=k, last=k;
    if(cnt == N && S.size()){
        cout<<-1;
        return 0;
    }
    while(cnt != N)
    {
        if(S.empty())
        {
            for(int j=N; j>=cur; j--)
                ans.push_back(j), S.pb(j);
            break;
        }
        int top=S.back();
        for(int j=top-1; j>0; j--)
        {
            if(vis[j] > 0)
            {
                break;
            }
            ++vis[j];
            S.pb(j);
            ++cnt;
            ans.pb(j);
        }
        if(cnt == last) break;
        last=cnt;
        while(S.size() && S.back() == cur) ++cur, S.pop_back();
    }
   // cout<<cur<<"\n";
   // for(int i=0;i<S.size();i++) cout<<S[i]<<" ";
    while(cur <= N && S.size() && S.back() == cur) cur++, S.pop_back();
    if(cur != N +1|| S.size()) cur=0;
    if(ans.size() +k < N || cur == 0)
    {
        cout<<-1;
        return 0;
    }
    for(int i=1; i<=k; i++ ) cout<<arr[i]<< " ";
    for(int i=0; i<ans.size(); i++) cout<<ans[i]<< ' ';
    return 0;

}


#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
const double PI = acos(-1.0), EPS = 1e-9;
const int MX=2*1e5+10;
int N, M, k;
int arr[MX];
vector<int> S;
int vis[MX];
int main()
{
    cin>>N>>k;
    for(int i=1; i<=k; i++)
    {
        cin>>arr[i];
        ++vis[arr[i]];
    }
    int cur=1;
    for(int i=1; i<=k; i++)
    {
        S.pb(arr[i]);
        while(S.back() == cur)
        {
            cur++;
            S.pop_back();
        }
    }
    ///  cout<<S.size()<<"\n";
    vector<int> ans;
    int cnt=k, last=k;
    if(cnt == N && S.size()){
        cout<<-1;
        return 0;
    }
    while(cnt != N)
    {
        if(S.empty())
        {
            for(int j=N; j>=cur; j--)
                ans.push_back(j);
            break;
        }
        int top=S.back();
        for(int j=top-1; j>0; j--)
        {
            if(vis[j] > 0)
            {
                break;
            }
            ++vis[j];
            S.pb(j);
            ++cnt;
            ans.pb(j);
        }
        if(cnt == last) break;
        last=cnt;
        while(S.size() && S.back() == cur) ++cur, S.pop_back();
    }
    if(ans.size() +k < N)
    {
        cout<<-1;
        return 0;
    }
    for(int i=1; i<=k; i++ ) cout<<arr[i]<< " ";
    for(int i=0; i<ans.size(); i++) cout<<ans[i]<< ' ';
    return 0;

}


#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
const double PI = acos(-1.0), EPS = 1e-9;
const int MX=2*1e5+10;
int N, M, k;
int arr[MX];
vector<int> S;
int vis[MX];
int main()
{
    cin>>N>>k;
    for(int i=1; i<=k; i++)
    {
        cin>>arr[i];
        ++vis[arr[i]];
    }
    int cur=1;
    for(int i=1; i<=k; i++)
    {
        int tp=1e7;
        if(S.size()) tp=S.back();
        S.pb(arr[i]);
        while(S.back() == cur)
        {
            cur++;
            S.pop_back();
        }
        if(arr[i] > tp){
            cout<<-1;
            return 0;
        }
    }
    ///  cout<<S.size()<<"\n";
    vector<int> ans;
    int cnt=k, last=k;
    if(cnt == N && S.size()){
        cout<<-1;
        return 0;
    }
    while(cnt != N)
    {
        if(S.empty())
        {
            for(int j=N; j>=cur; j--)
                ans.push_back(j), S.pb(j);
            break;
        }
        int top=S.back();
        for(int j=top-1; j>0; j--)
        {
            if(vis[j] > 0)
            {
                break;
            }
            ++vis[j];
            S.pb(j);
            ++cnt;
            ans.pb(j);
        }
        if(cnt == last) break;
        last=cnt;
        while(S.size() && S.back() == cur) ++cur, S.pop_back();
    }
   // cout<<cur<<"\n";
   // for(int i=0;i<S.size();i++) cout<<S[i]<<" ";
  ///  while(cur <= N && S.size() && S.back() == cur) cur++, S.pop_back();
   /// if(cur != N +1|| S.size()) cur=0;
    if(ans.size() +k < N || cur == 0)
    {
        cout<<-1;
        return 0;
    }
    for(int i=1; i<=k; i++ ) cout<<arr[i]<< " ";
    for(int i=0; i<ans.size(); i++) cout<<ans[i]<< ' ';
    return 0;

}


#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
const double PI = acos(-1.0), EPS = 1e-9;
const int MX=2*1e5+10;
int N, M, k;
int arr[MX];
vector<int> S;
int vis[MX];
int main()
{
    cin>>N>>k;
    for(int i=1; i<=k; i++)
    {
        cin>>arr[i];
        ++vis[arr[i]];
    }
    int cur=1;
    for(int i=1; i<=k; i++)
    {
        int tp=-1;
        if(S.size()) tp=S.back();
        S.pb(arr[i]);
        while(S.back() == cur)
        {
            cur++;
            S.pop_back();
        }
        if(arr[i] > tp){
            cout<<-1;
            return 0;
        }
    }
    ///  cout<<S.size()<<"\n";
    vector<int> ans;
    int cnt=k, last=k;
    if(cnt == N && S.size()){
        cout<<-1;
        return 0;
    }
    while(cnt != N)
    {
        if(S.empty())
        {
            for(int j=N; j>=cur; j--)
                ans.push_back(j), S.pb(j);
            break;
        }
        int top=S.back();
        for(int j=top-1; j>0; j--)
        {
            if(vis[j] > 0)
            {
                break;
            }
            ++vis[j];
            S.pb(j);
            ++cnt;
            ans.pb(j);
        }
        if(cnt == last) break;
        last=cnt;
        while(S.size() && S.back() == cur) ++cur, S.pop_back();
    }
   // cout<<cur<<"\n";
   // for(int i=0;i<S.size();i++) cout<<S[i]<<" ";
  ///  while(cur <= N && S.size() && S.back() == cur) cur++, S.pop_back();
   /// if(cur != N +1|| S.size()) cur=0;
    if(ans.size() +k < N || cur == 0)
    {
        cout<<-1;
        return 0;
    }
    for(int i=1; i<=k; i++ ) cout<<arr[i]<< " ";
    for(int i=0; i<ans.size(); i++) cout<<ans[i]<< ' ';
    return 0;

}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(i>=2&&a[i]>a[i-1]&&(a[i-1]-1!=now&&a[i-1]!=now))
		{
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(i>=2&&a[i]==a[i-1]-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
		sc(a[i]);
		vis[a[i]]=1;
		if(s.size()&&a[i]>s.top()&&(s.top()>now))
		{//cout<<"Sd";
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(s.size()&&a[i]==s.top()-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;

				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(s.size()&&a[i]>s.top()&&(s.top()>now))
		{//cout<<"Sd";
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(s.size()&&a[i]==s.top()-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;

				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
		sc(a[i]);
		vis[a[i]]=1;
		if(s.size()&&a[i]>s.top()&&(s.top()>now))
		{//cout<<"Sd";
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(s.size()&&a[i]==s.top()-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(s.size()&&a[i]>s.top()&&(s.top()>now))
		{//cout<<"Sd";
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(s.size()&&a[i]==s.top()-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t==3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	int p=a[k];
	while(--p&&!vis[p])
	{
		//cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t==3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t==3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(i>=2&&a[i]==a[i-1]-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t==3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(s.size()&&a[i]>s.top()&&(s.top()>now))
		{//cout<<"Sd";
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(i>=2&&a[i]==a[i-1]-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(i>=2&&a[i]>a[i-1]&&(a[i-1]>now))
		{//cout<<"Sd";
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(i>=2&&a[i]==a[i-1]-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(i>=2&&a[i]>a[i-1]&&(a[i-1]-1>now&&a[i-1]>now))
		{//cout<<"Sd";
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(i>=2&&a[i]==a[i-1]-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t==3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(i>=2&&a[i]==a[i-1]-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t==3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits\stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc(x) scanf("%d",&x)
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int a[200005],vis[200005];
int main(int argc, char** argv) {
	int n;
	sc(n);
	int k;
	sc(k);
	int now=1;
	stack<int>s;
	int t=0;
	rep(i,1,k)
	{
	sc(a[i]);
	vis[a[i]]=1;
		if(now==a[i])
		{
			now++;
			if(s.size())
			{
			int u=s.top();
			if(u==now)t--;
			while(u==now)
				{
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();
				}
			}
		}
		else
		{
			if(i>=2&&a[i]==a[i-1]-1)
			{
				s.push(a[i]);
			}
			else
			{
				t++;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}
	while(s.size())
	{
	int p=s.top();
	int q=s.top();
	//cout<<p<<endl;
	while(s.size()&&s.top()==q)
	{
		s.pop();
		q++;
	}
	while(--p&&!vis[p])
	{
	//	cout<<p<<endl;
		vis[p]=1;
		a[++k]=p;
	}
	}
	int q=n;
	while(vis[n])n--;
	if(n!=0)
	{
		while(n&&!vis[n])
		{
			//cout<<n<<endl;
			vis[n]=1;
			a[++k]=n--;
		}
	}
	while(!s.empty())s.pop();
	now=1;
	//cout<<k<<endl;
	t=0;
	rep(i,1,k)
	{

		if(a[i]>a[i-1]&&a[i-1]-1!=now&&a[i-1]!=now)
		{
			puts("-1");
			exit(0);
		}
		if(now==a[i])
		{

		//	cout<<a[i]<<endl;
			now++;
			if(s.size())
			{

			int u=s.top();if(u==now)t--;
			while(u==now)
				{
				//	cout<<now<<endl;
					now++;
					s.pop();
					if(!s.size())break;
					u=s.top();

				}
			}
		}
		else
		{

			if(i>=2&&a[i]==a[i-1]-1)
			{
			//	cout<<a[i]<<endl;
				s.push(a[i]);
			}
			else
			{//	cout<<now<<" "<<t<<endl;
				t++;
			//	cout<<now<<endl;
				if(t>3)
				{
					puts("-1");
					exit(0);
				}
				s.push(a[i]);
			}
		}
	}//printf("sd");
	rep(i,1,k)printf("%d ",a[i]);
	return 0;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n, k, i, num = 0, t;

vector<int> a, b;

stack<int> s;

map<int, int> mp;

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n >> k;

	num = n;

	for (i = 0; i < k; i++)
	{
		int x;
		cin >> x;
		num--;
		mp[x] = 1;
		a.push_back(x);
		if (s.size() && a[i] > s.top()) return cout << -1, 0;
		s.push(a[i]);
	}

	int tt = s.top();

	while (num)
	{
		if (!num) break;
		if (!tt) tt = n;
		if (!mp[tt])num--, a.push_back(tt), mp[tt] = 1;
		tt--;
	}

	for (i = 0; i < n; i++) cout << a[i] << ' ';

	return 0;
}


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

int a[300000], i, n, k, fs = 1, id;

stack<int> st;

map<int, bool> vis;

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n >> k;

	id = k;

	for (i = 0; i < k; i++)
		cin >> a[i], vis[a[i]] = true;

	for (i = 0; i < k; i++)
	{
		if (st.empty())
			st.push(a[i]);
		else
		{
			while (st.size() && st.top() < a[i])
			{
				if (st.top() != fs) return cout << -1, 0;
				st.pop(); fs++;
			}
			st.push(a[i]);
		}
	}
	/*
	for (int i = st.top();; i--)
	{
		if (i < fs)break;
		if (!vis[i]){
			a[id++] = i;
			vis[i] = true;
			fs++;
		}
	}
	*/
	while (st.size() && st.top() == fs)
	{
		st.pop();
		fs++;
	}

	if (st.empty())
	{
		for (int i = n; i > 0; i--)
		{
			if (!vis[i])
			{
				a[id++] = i;
				vis[i] = true;
			}
		}
		for (int i = 0; i < n; i++) cout << a[i] << ' ';
		return 0;
	}

	int pre = st.top();

	for (int i = st.top() - 1;; i--)
	{
		if (i < fs) break;
		a[id++] = i;
		vis[i] = true;
	}

	fs = pre;

	for (int i = n; i>0; i--)
	{
		if (!vis[i])
			a[id++] = i, vis[i] = true;
	}

	for (int i = 0; i < n; i++) cout << a[i] << ' ';

	return 0;
}


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

int a[300000], i, n, k, fs = 1, id;

stack<int> st;

map<int, bool> vis;

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n >> k;

	id = k;

	for (i = 0; i < k; i++)
		cin >> a[i], vis[a[i]] = true;

	for (i = 0; i < k; i++)
	{
		if (st.empty())
			st.push(a[i]);
		else
		{
			while (st.size() && st.top() < a[i])
			{
				if (st.top() != fs) return cout << -1, 0;
				st.pop(); fs++;
			}
			st.push(a[i]);
		}
	}

	while (st.size() && st.top() == fs)
	{
		st.pop();
		fs++;
	}

	if (st.empty())
	{
		for (int i = n; i > 0; i--)
		{
			if (!vis[i])
			{
				a[id++] = i;
				vis[i] = true;
			}
		}
		for (int i = 0; i < n; i++) cout << a[i] << ' ';
		return 0;
	}

	int pre = st.top();

	for (int i = st.top() - 1;; i--)
	{
		if (i < fs) break;
		a[id++] = i;
		vis[i] = true;
	}

	fs = pre;

	for (int i = n; i>0; i--)
	{
		if (!vis[i])
			a[id++] = i, vis[i] = true;
	}

	for (int i = 0; i < n; i++) cout << a[i] << ' ';

	return 0;
}


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

int a[300000], i, n, k, fs = 1, id;

stack<int> st;

bool vis[300000] = { false };

int main()
{
	//	ios_base::sync_with_stdio(false);

	//cin >> n >> k;

	scanf("%d%d", &n, &k);

	id = k;

	for (i = 0; i < k; i++)
		scanf("%d", &a[i]), vis[a[i]] = true;

	for (i = 0; i < k; i++)
	{
		if (st.empty())
			st.push(a[i]);
		else
		{
			while (st.size() && st.top() < a[i])
			{
				if (st.top() != fs) return cout << -1, 0;
				st.pop(); fs++;
			}
			st.push(a[i]);
		}
	}

	while (st.size())
	{
		for (int i = st.top() - 1;; i--)
		{
			if (i < fs) break;
			if (!vis[i]){
				a[id++] = i;
				vis[i] = true;
			}
		}
		fs = st.top();
		st.pop();
	}

	for (int i = n; i > 0; i--)
	{
		if (!vis[i])
			a[id++] = i, vis[i] = true;
	}

	for (int i = 0; i < n; i++) printf("%d ", a[i]);

	return 0;
}


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

int a[300000], i, n, k, fs = 1, id;

stack<int> st;

map<int, bool> vis;

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n >> k;

	id = k;

	for (i = 0; i < k; i++)
		cin >> a[i], vis[a[i]] = true;

	for (i = 0; i < k; i++)
	{
		if (st.empty())
			st.push(a[i]);
		else
		{
			if (st.top() < a[i])
			{
				if (st.top() != fs) return cout << -1, 0;
				st.pop();
				fs++;
			}
			st.push(a[i]);
		}
	}

	while (st.size() && st.top() == fs)
	{
		st.pop();
		fs++;
	}

	if (st.empty())
	{
		for (int i = n; i > 0; i--)
		{
			if (!vis[i])
			{
				a[id++] = i;
				vis[i] = true;
			}
		}
		for (int i = 0; i < n; i++) cout << a[i] << ' ';
		return 0;
	}

	int pre = st.top();

	for (int i = st.top()-1;; i--)
	{
		if (i < fs) break;
		a[id] = i;
		vis[a[id++]] = true;
	}

	fs = pre;

	for (int i = n; i>0; i--)
	{
		if (!vis[i])
			a[id++] = i, vis[i] = true;
	}

	for (int i = 0; i < n; i++) cout << a[i] << ' ';

	return 0;
}


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

int a[300000], i, n, k, fs = 1, id;

stack<int> st;

bool vis[300000] = { false };

int main()
{
	//	ios_base::sync_with_stdio(false);

	//cin >> n >> k;

	scanf("%d%d", &n, &k);

	id = k;

	for (i = 0; i < k; i++)
		scanf("%d", &a[i]), vis[a[i]] = true;

	for (i = 0; i < k; i++)
	{
		if (st.empty())
			st.push(a[i]);
		else
		{
			while (st.size() && st.top() < a[i])
			{
				if (st.top() != fs) return cout << -1, 0;
				st.pop(); fs++;
			}
			st.push(a[i]);
		}
	}

	while (st.size() && st.top() == fs)
	{
		st.pop();
		fs++;
	}

	if (st.empty())
	{
		for (int i = n; i > 0; i--)
		{
			if (!vis[i])
			{
				a[id++] = i;
				vis[i] = true;
			}
		}
		for (int i = 0; i < n; i++) cout << a[i] << ' ';
		return 0;
	}

	int pre = st.top();

	while (st.size())
	{
		for (int i = st.top() - 1;; i--)
		{
			if (i < fs) break;
			if (!vis[i]){
				a[id++] = i;
				vis[i] = true;
			}
		}
		fs = st.top();
		st.pop();
	}

//	fs = pre;

	for (int i = n; i > 0; i--)
	{
		if (!vis[i])
			a[id++] = i, vis[i] = true;
	}

	for (int i = 0; i < n; i++) printf("%d ", a[i]);

	return 0;
}


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

int a[300000], i, n, k, fs = 1, id;

stack<int> st;

map<int, bool> vis;

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> n >> k;

	id = k;

	for (i = 0; i < k; i++)
		cin >> a[i], vis[a[i]] = true;

	for (i = 0; i < k; i++)
	{
		if (st.empty())
			st.push(a[i]);
		else
		{
			while (st.size() && st.top() < a[i])
			{
				if (st.top() != fs) return cout << -1, 0;
				st.pop(); fs++;
			}
			st.push(a[i]);
		}
	}

	while (st.size() && st.top() == fs)
	{
		st.pop();
		fs++;
	}

	if (st.empty())
	{
		for (int i = n; i > 0; i--)
		{
			if (!vis[i])
			{
				a[id++] = i;
				vis[i] = true;
			}
		}
		for (int i = 0; i < n; i++) cout << a[i] << ' ';
		return 0;
	}

	int pre = st.top();

	while (st.size())
	{
		for (int i = st.top() - 1;; i--)
		{
			if (i < fs) break;
			if (!vis[i]){
				a[id++] = i;
				vis[i] = true;
			}
		}
		st.pop();
	}

	fs = pre;

	for (int i = n; i>0; i--)
	{
		if (!vis[i])
			a[id++] = i, vis[i] = true;
	}

	for (int i = 0; i < n; i++) cout << a[i] << ' ';

	return 0;
}


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

const int MAXN = 210000;

int n,k;
int a[MAXN];
stack<int> S;
int vis[MAXN];
int ans[MAXN],cnt;
int fi,st;

int main(){
  scanf("%d %d",&n,&k);
  for(int i = 1;i<=k;i++){
    scanf("%d",&a[i]);
    vis[a[i]] = 1;
  }
  vis[n+1] = 1;
  int now = 1;
  for(int i = 1;i<=k;i++){
    while(!S.empty() && S.top() == now){
      vis[now] = 0;
      now++;
      S.pop();
    }
    if(now == a[i]){
      now++;
      vis[a[i]] = 0;
    }
    else{
      S.push(a[i]);
    }
    ans[++cnt] = a[i];
  }
  int minn = 0;
  while(vis[minn] == 0) minn++;
  bool flag = 1;
  while(flag){
    flag = 0;
    while(!S.empty() && S.top() == now){
      vis[now] = 0;
      now++;
      S.pop();
      flag = 1;
    }
    while(vis[minn] == 0) minn++;
    for(int i = minn-1;i>=now;i--){
      ans[++cnt] = i;
      flag = 1;
    }
    now = minn;
  }
  if(now >= n){
    for(int i = 1;i<=n;i++){
      printf("%d ",ans[i]);
    }
    printf("\n");
  }
  else{
    printf("-1\n");
  }
  return 0;
}


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

const int MAXN = 210000;

int n,k;
int a[MAXN];
stack<int> S;
int vis[MAXN];
int instack[MAXN];
int ans[MAXN],cnt;
int fi,st;

int main(){
  scanf("%d %d",&n,&k);
  for(int i = 1;i<=k;i++){
    scanf("%d",&a[i]);
    vis[a[i]] = 1;
  }
  int now = 1;
  for(int i = 1;i<=k;i++){
    if(now == a[i]){
      now++;
    }
    else{
      S.push(a[i]);
      instack[a[i]] = 1;
    }
    ans[++cnt] = a[i];
  }
  bool flag = 1;
  while(flag){
    flag = 0;
    while(!S.empty() && S.top() == now){
      now++;
      S.pop();
      flag = 1;
    }
    while(vis[now] == 0){
      flag = 1;
      ans[++cnt] = now;
      now++;
    }
  }
  if(now >= n){
    for(int i = 1;i<=n;i++){
      printf("%d ",ans[i]);
    }
    printf("\n");
  }
  else{
    printf("-1\n");
  }
  return 0;
}


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

const int MAXN = 210000;

int n,k;
int a[MAXN];
stack<int> S;
int vis[MAXN];
int instack[MAXN];
int ans[MAXN],cnt;
int fi,st;

int main(){
  scanf("%d %d",&n,&k);
  for(int i = 1;i<=k;i++){
    scanf("%d",&a[i]);
    vis[a[i]] = 1;
  }
  vis[n+1] = 1;
  int now = 1;
  for(int i = 1;i<=k;i++){
    if(now == a[i]){
      now++;
      vis[a[i]] = 0;
    }
    else{
      S.push(a[i]);
      instack[a[i]] = 1;
    }
    ans[++cnt] = a[i];
  }
  int minn = 0;
  while(vis[minn] == 0) minn++;
  bool flag = 1;
  while(flag){
    flag = 0;
    while(!S.empty() && S.top() == now){
      vis[now] = 0;
      now++;
      S.pop();
      flag = 1;
    }
    while(vis[minn] == 0) minn++;
    for(int i = minn-1;i>=now;i--){
      ans[++cnt] = i;
      flag = 1;
    }
    now = minn;
  }
  if(now >= n){
    for(int i = 1;i<=n;i++){
      printf("%d ",ans[i]);
    }
    printf("\n");
  }
  else{
    printf("-1\n");
  }
  return 0;
}


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

const int MAXN = 210000;

int n,k;
int a[MAXN];
stack<int> S;
int vis[MAXN];
int instack[MAXN];
int ans[MAXN],cnt;
int fi,st;

int main(){
  scanf("%d %d",&n,&k);
  for(int i = 1;i<=k;i++){
    scanf("%d",&a[i]);
    vis[a[i]] = 1;
  }
  int now = 1;
  for(int i = 1;i<=k;i++){
    if(now == a[i]){
      now++;
    }
    else{
      S.push(a[i]);
      instack[a[i]] = 1;
    }
    ans[++cnt] = a[i];
  }
  bool flag = 1;
  while(flag){
    flag = 0;
    while(!S.empty() && S.top() == now){
      now++;
      S.pop();
      flag = 1;
    }
    if(S.empty()){
      for(int i = n;i>=now;--i){
        ans[++cnt] = i;
      }
      now = n+1;
      break;
    }
    while(vis[now] == 0){
      flag = 1;
      ans[++cnt] = now;
      now++;
    }
  }
  if(now >= n){
    for(int i = 1;i<=n;i++){
      printf("%d ",ans[i]);
    }
    printf("\n");
  }
  else{
    printf("-1\n");
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[400033],pp;
int main()
{
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++)
		scanf("%d",&arr[i]);
	stack<int>s;
	int curr=1,pos=1;
	for(i=0;i<k;i++)
	{
		if(arr[i]==curr)
			curr++;
		else
			s.push(arr[i]);
		while(!s.empty()&&s.top()==curr)
		{
			curr++;
			s.pop();
		}
	}
	if(k==n)
	{
		if(curr==(n+1))
			for(i=0;i<k;i++)
				printf("%d ",arr[i]);
		else
			printf("-1");
		return 0;
	}
	while(1)
	{
		if(s.empty())
		{
			int aa=n;
			while(k<n)
			{
				arr[k++]=aa--;
			}
				for(i=0;i<k;i++)
				printf("%d ",arr[i]);
			return 0;
		}
		else
		{
			int aa=s.top()-1;
			if(aa+1<curr)
			{
				printf("-1");
				return 0;
			}
			while(k<n&&aa>=curr)
			{
				arr[k++]=aa--;
			}
			curr=s.top()+1;
			s.pop();
		//	cout<<curr<<endl;
		}
		if(k>n)
		{
			printf("-1");
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[400033],pp;
int main()
{
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++)
		scanf("%d",&arr[i]);
	stack<int>s;
	int curr=1,pos=1;
	for(i=0;i<k;i++)
	{
		if(arr[i]==curr)
			curr++;
		else
			s.push(arr[i]);
		while(!s.empty()&&s.top()==curr)
		{
			curr++;
			s.pop();
		}
	}
	if(k==n)
	{
		if(curr==(n+1))
			for(i=0;i<k;i++)
				printf("%d ",arr[i]);
		else
			printf("-1");
		return 0;
	}
	while(1)
	{
		if(s.empty())
		{
			int aa=n;
			while(k<n)
			{
				arr[k++]=aa--;
			}
				for(i=0;i<k;i++)
				printf("%d ",arr[i]);
			return 0;
		}
		else
		{
			int aa=s.top()-1;
			if(aa<curr)
			{
				printf("-1");
				return 0;
			}
			while(k<n&&aa>=curr)
			{
				arr[k++]=aa--;
			}
			curr=s.top()+1;
			s.pop();
		//	cout<<curr<<endl;
		}
		if(k>n)
		{
			printf("-1");
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[400033],pp;
int main()
{
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++)
		scanf("%d",&arr[i]);
	stack<int>s;
	int curr=1,pos=1;
	for(i=0;i<k;i++)
	{
		if(arr[i]==curr)
			curr++;
		else
			s.push(arr[i]);
		while(!s.empty()&&s.top()==curr)
		{
			curr++;
			s.pop();
		}
	}
	if(k==n)
	{
		if(curr==(n+1))
			for(i=0;i<k;i++)
				printf("%d ",arr[i]);
		else
			printf("-1");
		return 0;
	}
	while(1)
	{
		if(s.empty())
		{
			int aa=n;
			while(k<n)
			{
				arr[k++]=aa--;
			}
				for(i=0;i<k;i++)
				printf("%d ",arr[i]);
			return 0;
		}
		else
		{
			int aa=s.top()-1;
			if(aa<curr)
			{
				printf("-1");
				return 0;
			}
			while(k<n&&aa>=curr)
			{
				arr[k++]=aa--;
			}
			curr=s.top();
			while(!s.empty()&&s.top()==curr)
			{
				s.pop();
				curr++;
			}
		//	cout<<curr<<endl;
		}
		if(k>n)
		{
			printf("-1");
			return 0;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int arr[200033],pp;
int main()
{
	int n,k,i;
	scanf("%d%d",&n,&k);
	for(i=0;i<k;i++)
		scanf("%d",&arr[i]);

	stack<int>s;
	int curr=1,pos=1;
	for(i=0;i<k;i++)
	{
		if(arr[i]==curr)
			curr++;
		else
			s.push(arr[i]);
		while(!s.empty()&&s.top()==curr)
		{
			curr++;
			s.pop();
		}
	}
	if(k==n)
	{
		if(curr==(n+1))
			for(i=0;i<k;i++)
				printf("%d ",arr[i]);
		else
			printf("-1");
		return 0;
	}
	while(1)
	{
		if(s.empty())
		{
			int aa=n;
			while(k<n)
			{
				arr[k++]=aa--;
			}
				for(i=0;i<k;i++)
				printf("%d ",arr[i]);
			return 0;
		}
		else
		{
			int aa=s.top()-1;
			if(aa<curr)
			{
				printf("-1");
				return 0;
			}
			while(aa>=curr)
			{
				arr[k++]=aa--;
			}
			curr=s.top()+1;
			s.pop();
		//	cout<<curr<<endl;
		}
	}
	return 0;
}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

string aux = "#$%";
int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;
	int m = str.size() ,k = 0;
	for(int i = 1; i < m ;i++){
		if(str[i] == str[i-1])str[i] = aux[k++];
		if (k > 2)k = 0;
	}

	cout << str;
}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;

	for(int i = 1; str[i] ;i++){
		char aux = str[i+1];
		if ( str[i] == str[i-1])str[i] = ++aux;
	}

}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

string aux = "y3w";
int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;
	int m = str.size() ,k = 0;
	for(int i = 1; i < m ;i++){
		if(str[i] == str[i-1])str[i] = aux[k++];
		if (k > 2)k = 0;
	}

	cout << str;
}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;
	int m = str.size();
	for(int i = 1; i < m - 1 ;i++){
		char aux = str[i+1];
		if ( str[i] == str[i-1])str[i] = ++aux;
	}
	cout << str;
}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

string aux = "zbrfwk";

int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;
	int m = str.size() ,k = 0;
	for(int i = 1; i < m ;i++){
		if(str[i] == str[i-1])str[i] = aux[k++];
		if(k > 2)k = 0;
		if(i+1 != m and  str[i]==str[i+1])str[i] = aux[k++];
		if(k > 2)k = 0;
	}

	cout << str;
}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

string aux = "zbrfwk";

int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;
	int m = str.size() ,k = 0;
	for(int i = 1; i < m ;i++){
		if(str[i] == str[i-1]) {
			str[i] = aux[k++];
			if(k > 2)k = 0;
			if(i+1 != m and str[i]==str[i+1])str[i] = aux[k++];
			if(k > 2)k = 0;
		}
	}

	cout << str;
}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

string aux = "zbrfwk";

char sel (char a, char x,  char b){
	int k = 1;
	while ( (( x-97 + k)%26 ) + 97 == a or (( x-97 + k)%26 ) + 97 == b )k++;
	return (( x-97 + k)%26 ) + 97;
}

int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;
	int m = str.size();
	for(int i = 1; i < m ;i++){
		if(str[i] == str[i-1])str[i] = sel(str[i-1],str[i],str[i+1]);
	}

	cout << str;
}


#include<stdio.h>
#include<bitset>
#include<iostream>
#include<set>
#include<string.h>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<limits>
#include<math.h>
#include<string.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;

#define pb push_back
#define ii pair<int, int>
#define iii pair<int, ii >
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int mod = 1000000007;
const int maxn = 1e6;
const int MAX = 1e4 + 10;

int main (){
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	string str;	 cin >> str;
	int m = str.size();
	for(int i = 1; i < m - 1 ;i++){
		int k = 1;
		while(str[i]==str[i-1] or str[i]==str[i+1])str[i] = ( (str[i]-97 + k)%26 ) + 97,k+=3;
	}
	char aux = str[m-1];
	if (m > 2 and str[m-2] == aux)str[m-2] = ( (aux-97 + 3)%26 ) + 97;

	cout << str;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
int main() {
	cin >> str + 1;
	int n = strlen(str + 1);
	for (int i = 2; i <= n; i++) {
		if (str[i - 1] == str[i] && str[i] == str[i + 1]) {
			str[i] = (str[i] + 1) % 10 + 'a';
		} else if (str[i - 1] == str[i]) {
			str[i - 1] = (str[i - 1] + 1) % 10 + 'a';
		}
	}
	cout << str + 1 << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
int main() {
	cin >> str + 1;
	int n = strlen(str + 1);
	for (int i = 2; i <= n; i++) {
		if (str[i - 1] == str[i] && str[i] == str[i + 1]) {
			str[i] = (str[i - 1] + 1) % rand()%20 + 'a';
		} else if (str[i - 1] == str[i]) {
			str[i] = (str[i - 1] + 1) % rand()%20 + 'a';
		}
	}
	cout << str + 1 << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
char get() {
	return rand() % 26 + 'a';
}
int main() {
	char ch;
	srand(time(0));
	cin >> str + 1;
	int n = strlen(str + 1);
	for (int i = 2; i <= n; i++) {
		if (str[i - 1] == str[i] && str[i] == str[i + 1]) {
			while ((ch = get()) == str[i]);
			str[i] = ch;
		} else if (str[i - 1] == str[i]) {
			while ((ch = get()) == str[i] || ch == str[i + 1]);
			str[i] = ch;
		}
	}
	cout << str + 1 << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
int main() {
	cin >> str + 1;
	int n = strlen(str + 1);
	for (int i = 2; i <= n; i++) {
		if (str[i - 1] == str[i] && str[i] == str[i + 1]) {
			str[i] = (str[i - 1] + 1) % 10 + 'a';
		} else if (str[i - 1] == str[i]) {
			str[i] = (str[i + 1] + 1) % 10 + 'a';
		}
	}
	cout << str + 1 << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
int main() {
	cin >> str + 1;
	int n = strlen(str + 1);
	for (int i = 2; i <= n; i++) {
		if (str[i - 1] == str[i] && str[i] == str[i + 1]) {
			str[i] = (str[i - 1] + 1) % 10 + 'a';
		} else if (str[i - 1] == str[i]) {
			str[i] = (str[i - 1] + 1) % 10 + 'a';
		}
	}
	cout << str + 1 << endl;
	return 0;
}


#include <iostream>
#include<iomanip>
#include<string.h>
#include<vector>
#include<set>
#include<math.h>
#include <algorithm>
#include <stdlib.h>
#include <unordered_map>
#include<unordered_set>
#include <utility>
#include<queue>
#include<limits.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int

using namespace std;

int main()
{
    IOS
    string s;
    char temp = 'a';
    cin >> s;
    ll n, i, j, k, c = 0;
    n = s.size();
    unordered_set<char> st;
    for (i = 0; i < n; i++)
        st.insert(s[i]);
    for (char ch = 'a'; ch <='z'; ch++)
    {
        if(st.count(ch)==0)
        {
            temp = ch;
            break;
        }
    }
        for (i = 0; i < n; i++)
        {
            if (s[i] == s[i + 1])
            {

                for (j = i + 1; j < n; j++)
                {
                    if (s[j] != s[j + 1])
                        break;
                }
                c = i - j + 1;
                if(c%2==0)
                {
                    for (k = i; k < j; k=k+2)
                    {
                        s[k] = temp;
                    }
                }
                else
                {
                    for (k = i+1; k < j; k=k+2)
                    {
                        s[k] = temp;
                    }
                }

                i = j;
            }
        }
    cout << s;

    return 0;
}


#include <iostream>
#include<iomanip>
#include<string.h>
#include<vector>
#include<set>
#include<math.h>
#include <algorithm>
#include <stdlib.h>
#include <unordered_map>
#include<unordered_set>
#include <utility>
#include<queue>
#include<limits.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int

using namespace std;

int main()
{
    IOS
    string s;
    char temp = 'a';
    cin >> s;
    ll n, i, j, k, c = 0;
    n = s.size();
    /*unordered_set<char> st;
    for (i = 0; i < n; i++)
        st.insert(s[i]);
    for (char ch = 'a'; ch <='z'; ch++)
    {
        if(st.count(ch)==0)
        {
            temp = ch;
            break;
        }
    }*/
        for (i = 0; i < n; i++)
        {
            //cout << s[i] <<"  "<< s[i + 1] << "\n";
            if (s[i] == s[i + 1])
            {
                j = i + 1;
                for (; j < n; j++)
                {
                    if (s[j] != s[j + 1])
                        break;
                }
                //cout << "j = " << j << "  ";
                c = i - j + 1;
                if(c%2==0)

                    for (k = i; k <= j; )
                    {
                        if(s[k]+1 != s[k+1] && s[k]+1 != s[k-1])
                        {

                            s[k]++;
                            k = k + 2;
                        }
                        else
                        {
                            k++;
                            s[k]++;
                            k++;
                        }

                    }

                else
                {
                    for (k = i+1; k < j; )
                    {
                        if(s[k]+1 != s[k+1] && s[k]+1 != s[k-1])
                        {

                            s[k]++;
                            k = k + 2;
                        }
                        else
                        {
                            k++;
                            s[k]++;
                            k++;
                        }
                    }
                }
                //cout << s << "\n";

                i = j-1;
            }
        }
    cout << s;

    return 0;
}


#include <iostream>
#include<iomanip>
#include<string.h>
#include<vector>
#include<set>
#include<math.h>
#include <algorithm>
#include <stdlib.h>
#include <unordered_map>
#include<unordered_set>
#include <utility>
#include<queue>
#include<limits.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int

using namespace std;

int main()
{
    IOS
    string s;
    char temp, c1='$', c2='$';
    cin >> s;
    ll n, i, j, k, c = 0;
    n = s.size();
    for (i = 0; i < n; i++)
    {
        //cout << "i=" << i << " ";
        c1 = '$', c2 = '$';
        if (s[i] == s[i + 1])
        {

            for (j = i + 1; j < n; j++)
            {
                if (s[j] != s[j + 1])
                break;
            }
            if (i == 0 && j == n - 1)
                {
                   c1 = '$', c2 = '$';
                }
            else if (i == 0 && j < n - 1)
            {
                c2 = s[j + 1];
            }
            else if (i > 0 && j < n - 1)
            {
                c1 = s[i - 1];
                c2 = s[j + 1];
            }

            //cout << c1 << "  " << c2<<"\n";

            for (char ch = 'a'; ch <= 'z'; ch++)
            {
                //cout << ch << " ";
                if (ch != c1 && ch != c2 && ch != s[i])
                {
                    temp = ch;
                    break;
                }
            }
            //cout << "i=" << i << " ";
            //cout << "temp =" << temp<<"\n" ;
            for (k = i + 1; k <= j; k=k+2)
            {
                //cout << "k= " << k;
                s[k] = temp;
            }
            i = j;
        }

    }

    cout << s;

    return 0;
}


#include <iostream>
#include<iomanip>
#include<string.h>
#include<vector>
#include<set>
#include<math.h>
#include <algorithm>
#include <stdlib.h>
#include <unordered_map>
#include<unordered_set>
#include <utility>
#include<queue>
#include<limits.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int

using namespace std;

int main()
{
    IOS
    string s;
    char temp;
    cin >> s;
    ll n, i, j, k, c = 0;
    n = s.size();
    unordered_set<char> st;
    for (i = 0; i < n; i++)
        st.insert(s[i]);
    for (char ch = 'a'; i <='z'; ch++)
    {
        if(st.count(ch)==0)
        {
            temp = ch;
            break;
        }
    }
        for (i = 0; i < n; i++)
        {
            if (s[i] == s[i + 1])
            {

                for (j = i + 1; j < n; j++)
                {
                    if (s[j] != s[j + 1])
                        break;
                }
                c = i - j + 1;
                if(c%2==0)
                {
                    for (k = i; k < j; k=k+2)
                    {
                        s[k] = temp;
                    }
                }
                else
                {
                    for (k = i+1; k < j; k=k+2)
                    {
                        s[k] = temp;
                    }
                }

                i = j;
            }
        }
    cout << s;

    return 0;
}


#include <iostream>
#include<iomanip>
#include<string.h>
#include<vector>
#include<set>
#include<math.h>
#include <algorithm>
#include <stdlib.h>
#include <unordered_map>
#include<unordered_set>
#include <utility>
#include<queue>
#include<limits.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int

using namespace std;

int main()
{
    IOS
    string s;
    char temp = 'a';
    cin >> s;
    ll n, i, j, k, c = 0;
    n = s.size();
    /*unordered_set<char> st;
    for (i = 0; i < n; i++)
        st.insert(s[i]);
    for (char ch = 'a'; ch <='z'; ch++)
    {
        if(st.count(ch)==0)
        {
            temp = ch;
            break;
        }
    }*/
        for (i = 0; i < n; i++)
        {
            if (s[i] == s[i + 1])
            {
                j = i + 1;
                for (; j < n; j++)
                {
                    if (s[j] != s[j + 1])
                        break;
                }
                //cout << "j = " << j << "  ";
                c = i - j + 1;
                if(c%2==0)

                    for (k = i; k <= j; )
                    {
                        if(s[k]+1 != s[k+1] && s[k]+1 != s[k-1])
                        {

                            s[k]++;
                            k = k + 2;
                        }
                        else
                        {
                            k++;
                            s[k]++;
                            k++;
                        }

                    }

                else
                {
                    for (k = i+1; k < j; )
                    {
                        if(s[k]+1 != s[k+1] && s[k]+1 != s[k-1])
                        {

                            s[k]++;
                            k = k + 2;
                        }
                        else
                        {
                            k++;
                            s[k]++;
                            k++;
                        }
                    }
                }

               // i = j;
            }
        }
    cout << s;

    return 0;
}


#include <bits/stdc++.h>
#define fast(IO) ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main()
{
    fast(IO);
    string s;
    int n;
    cin >> s;
    n = s.length();
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i+1] = max(s[i],s[i+2]);
            if(s[i+1]=='z')
            {
                s[i+1] = min(s[i],s[i+2]) - 1;
            }
            else
            {
                s[i+1]++;
            }
        }
    }
    cout << s << endl;
}


#include <bits/stdc++.h>
#define fast(IO) ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main()
{
    fast(IO);
    string s;
    int n;
    cin >> s;
    n = s.length();
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i+1] = max(s[i],s[i+2]);
            if(s[i+1]=='z')
            {
                if(min(s[i],s[i+1])=='z')
                {
                    s[i+1] = 'y';
                }
            }
            else
            {
                s[i+1]++;
            }
        }
    }
    cout << s << endl;
}


#include <bits/stdc++.h>
#define fast(IO) ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main()
{
    fast(IO);
    string s;
    int n;
    cin >> s;
    n = s.length();
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i+1] = max(s[i],s[i+2]);
            if(s[i+1]=='z')
            {
                if(min(s[i],s[i+2])!='a')
                {
                    s[i+1] = 'a';
                }
                else
                {
                    s[i+1] = min(s[i],s[i+2]) - 1;
                }
            }
            else
            {
                s[i+1]++;
            }
        }
    }
    cout << s << endl;
}


#include <bits/stdc++.h>
#define fast(IO) ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main()
{
    fast(IO);
    string s;
    int n;
    cin >> s;
    n = s.length();
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i+1] = max(s[i],s[i+2]);
            if(s[i+1]=='z')
            {
                if(min(s[i],s[i+2])!='a')
                {
                    s[i+1] = 'a';
                }
                else
                {
                    s[i+1] = max(s[i],s[i+2]) - 1;
                    if(s[i+1] == min(s[i],s[i+2]))
                    {
                        s[i+1]= 'c';
                    }
                }
            }
            else
            {
                s[i+1]++;
            }
        }
    }
    cout << s << endl;
}


#include <bits/stdc++.h>
#define fast(IO) ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main()
{
    fast(IO);
    string s;
    int n;
    cin >> s;
    n = s.length();
    for(int i=0;i<n-1;i++)
    {
        if(s[i]==s[i+1])
        {
            s[i+1] = max(s[i],s[i+2]);
            if(s[i+1]=='z')
            {
                s[i+1] = min(s[i],s[i+2]) + abs((s[i+2] - s[i]));
            }
            else
            {
                s[i+1]++;
            }
        }
    }
    cout << s << endl;
}


#include <bits/stdc++.h>

using namespace std;

char s[200001];

int main(){
  scanf("%s", &s[0]);
  int n = strlen(s);

  for (int i = 0; i < n; i++) {
    int start = i;
    int end = i + 1;
    while(end < n && s[start] == s[end]) {
      end++;
    }
    char change;
    if (end - start > 1){
      if (start >= 1) {
        change = s[start - 1];
      } else if (n - end > 1) {
        change = s[end + 1];
      } else {
        change = 'z';
      }
      for (int j = start + 1; j < end; j += 2) {
        s[j] = change;
      }
    }
    i = end - 1;
  }

  cout << s;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

char s[200001];

string alph = "abcdefghijklmnopqrstuvwxyz";

int main(){
  scanf("%s", &s[0]);
  int n = strlen(s);

  for (int i = 0; i < n; i++) {
    int start = i;
    int end = i + 1;
    while(end < n && s[start] == s[end]) {
      end++;
    }
    char change;
    if (end - start > 1){
      for (int j = 0; j < 27; j++) {
        if (alph[j] != s[start - 1] && alph[j] != s[end] &&  alph[j] != s[start]){
          change = alph[j];
          break;
        }
      }
      for (int j = start + 1; j < end; j += 2) {
        s[j] = change;
      }
    }
    i = end - 1;
  }

  cout << s;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

char s[200001];

int main(){
  scanf("%s", &s[0]);
  int n = strlen(s);

  for (int i = 0; i < n; i++) {
    if (s[i] == s[i - 1] && s[i] != s[i + 1]) {
      s[i] = s[i - 2];
    } else if (s[i] == s[i + 1] && s[i + 1] != s[i + 2]) {
      s[i] = s[i - 2];
    }
  }
  cout << s;
  return 0;
}