#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define fren bigounce
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define usaco(in,out) ifstream cin(in); ofstream cout(out)
#define beg begin()
#define end end()
#define all(X) (X).beg, (X).end
#define sz(X) ((int)X.size())
#define sqr(x) (x*x)
#define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
#define decimal(X) cout << fixed << setprecision(X)
#define mst(X,Y) memset(X,Y,sizeof(X));

typedef long long LL;
typedef double DBL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<string, int> PSI;
typedef pair<int,string> PIS;
typedef vector<PSI> VPSI;
typedef vector<PIS> VPIS;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef vector<PCI> VPCI;
typedef vector<PIC> VPIC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef vector< VI > VVI;
typedef vector< VLL > VVLL;

template<class T> void amax(T & a, const T & b) { a = max(a, b); }
template<class T> void amin(T & a, const T & b) { a = min(a, b); }

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "{";
  for(int i=0;i<sz(V);++i) {if(i==sz(V)-1) os << V[i]; else os << V[i] << ",";}
  return os << "}";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.ff << "," << P.ss << ")";
}

template<class TH> void _dbg(const char *sdbg, TH h) {cerr<<sdbg<<" = "<<h<<endl;}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#define LOCAL
#define SEPERATOR cout << "-----------------------------------------" << endl;

#ifdef LOCAL
	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
	#define cerr if(0)cout
#endif

const int maxn = 2e5+7;
const int inf = 1e9+7;
const LL LLinf = ((LL)1e18)+7LL;
const DBL pi = acos(-1.0);

// **************************************** CODE **************************************** //

LL n, k, maxi;

int32_t main() {
	speedup

	cin >> n >> k;
	VI a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	for (int i = 0; i < min(n,k+1); ++i) {
		if (a[i] > maxi) {maxi = a[i]; if (i > 0) k += i;}
	}

	cout << maxi;
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define fren bigounce
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define usaco(in,out) ifstream cin(in); ofstream cout(out)
#define beg begin()
#define end end()
#define all(X) (X).beg, (X).end
#define sz(X) ((int)X.size())
#define sqr(x) (x*x)
#define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
#define decimal(X) cout << fixed << setprecision(X)
#define mst(X,Y) memset(X,Y,sizeof(X));

typedef long long LL;
typedef double DBL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<string, int> PSI;
typedef pair<int,string> PIS;
typedef vector<PSI> VPSI;
typedef vector<PIS> VPIS;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef vector<PCI> VPCI;
typedef vector<PIC> VPIC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef vector< VI > VVI;
typedef vector< VLL > VVLL;

template<class T> void amax(T & a, const T & b) { a = max(a, b); }
template<class T> void amin(T & a, const T & b) { a = min(a, b); }

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "{";
  for(int i=0;i<sz(V);++i) {if(i==sz(V)-1) os << V[i]; else os << V[i] << ",";}
  return os << "}";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.ff << "," << P.ss << ")";
}

template<class TH> void _dbg(const char *sdbg, TH h) {cerr<<sdbg<<" = "<<h<<endl;}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#define LOCAL
#define SEPERATOR cout << "-----------------------------------------" << endl;

#ifdef LOCAL
	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
	#define cerr if(0)cout
#endif

const int maxn = 2e5+7;
const int inf = 1e9+7;
const LL LLinf = ((LL)1e18)+7LL;
const DBL pi = acos(-1.0);

// **************************************** CODE **************************************** //

LL n, k, maxi;

int32_t main() {
	speedup

	cin >> n >> k;
	VI a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	for (int i = 0; i < min(n,k+1); ++i) {
		if (a[i] > maxi) {maxi = a[i]; k++;}
	}

	cout << maxi;
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define fren bigounce
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define usaco(in,out) ifstream cin(in); ofstream cout(out)
#define beg begin()
#define end end()
#define all(X) (X).beg, (X).end
#define sz(X) ((int)X.size())
#define sqr(x) (x*x)
#define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
#define decimal(X) cout << fixed << setprecision(X)
#define mst(X,Y) memset(X,Y,sizeof(X));

typedef long long LL;
typedef double DBL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<string, int> PSI;
typedef pair<int,string> PIS;
typedef vector<PSI> VPSI;
typedef vector<PIS> VPIS;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef vector<PCI> VPCI;
typedef vector<PIC> VPIC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef vector< VI > VVI;
typedef vector< VLL > VVLL;

template<class T> void amax(T & a, const T & b) { a = max(a, b); }
template<class T> void amin(T & a, const T & b) { a = min(a, b); }

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "{";
  for(int i=0;i<sz(V);++i) {if(i==sz(V)-1) os << V[i]; else os << V[i] << ",";}
  return os << "}";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.ff << "," << P.ss << ")";
}

template<class TH> void _dbg(const char *sdbg, TH h) {cerr<<sdbg<<" = "<<h<<endl;}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#define LOCAL
#define SEPERATOR cout << "-----------------------------------------" << endl;

#ifdef LOCAL
	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
	#define cerr if(0)cout
#endif

const int maxn = 2e5+7;
const int inf = 1e9+7;
const LL LLinf = ((LL)1e18)+7LL;
const DBL pi = acos(-1.0);

// **************************************** CODE **************************************** //

LL n, k, maxi;

int32_t main() {
	speedup

	cin >> n >> k;
	VI a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	for (int i = 0; i < min(n,k+1); ++i) {
		if (a[i] > maxi) maxi = a[i];
	}

	cout << maxi;
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define fren bigounce
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define usaco(in,out) ifstream cin(in); ofstream cout(out)
#define beg begin()
#define end end()
#define all(X) (X).beg, (X).end
#define sz(X) ((int)X.size())
#define sqr(x) (x*x)
#define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
#define decimal(X) cout << fixed << setprecision(X)
#define mst(X,Y) memset(X,Y,sizeof(X));

typedef long long LL;
typedef double DBL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<string, int> PSI;
typedef pair<int,string> PIS;
typedef vector<PSI> VPSI;
typedef vector<PIS> VPIS;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef vector<PCI> VPCI;
typedef vector<PIC> VPIC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef vector< VI > VVI;
typedef vector< VLL > VVLL;

template<class T> void amax(T & a, const T & b) { a = max(a, b); }
template<class T> void amin(T & a, const T & b) { a = min(a, b); }

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "{";
  for(int i=0;i<sz(V);++i) {if(i==sz(V)-1) os << V[i]; else os << V[i] << ",";}
  return os << "}";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.ff << "," << P.ss << ")";
}

template<class TH> void _dbg(const char *sdbg, TH h) {cerr<<sdbg<<" = "<<h<<endl;}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#define LOCAL
#define SEPERATOR cout << "-----------------------------------------" << endl;

#ifdef LOCAL
	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
	#define cerr if(0)cout
#endif

const int maxn = 2e5+7;
const int inf = 1e9+7;
const LL LLinf = ((LL)1e18)+7LL;
const DBL pi = acos(-1.0);

// **************************************** CODE **************************************** //

LL n, k, maxi;

int32_t main() {
	speedup

	cin >> n >> k;
	VI a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	for (int i = 0; i < min(n,k+1); ++i) {
		if (a[i] > maxi) {maxi = a[i]; if (i > 0) k++;}
	}

	cout << maxi;
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define fren bigounce
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define usaco(in,out) ifstream cin(in); ofstream cout(out)
#define beg begin()
#define end end()
#define all(X) (X).beg, (X).end
#define sz(X) ((int)X.size())
#define sqr(x) (x*x)
#define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
#define decimal(X) cout << fixed << setprecision(X)
#define mst(X,Y) memset(X,Y,sizeof(X));

typedef long long LL;
typedef double DBL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<string, int> PSI;
typedef pair<int,string> PIS;
typedef vector<PSI> VPSI;
typedef vector<PIS> VPIS;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef vector<PCI> VPCI;
typedef vector<PIC> VPIC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef vector< VI > VVI;
typedef vector< VLL > VVLL;

template<class T> void amax(T & a, const T & b) { a = max(a, b); }
template<class T> void amin(T & a, const T & b) { a = min(a, b); }

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "{";
  for(int i=0;i<sz(V);++i) {if(i==sz(V)-1) os << V[i]; else os << V[i] << ",";}
  return os << "}";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.ff << "," << P.ss << ")";
}

template<class TH> void _dbg(const char *sdbg, TH h) {cerr<<sdbg<<" = "<<h<<endl;}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#define LOCAL
#define SEPERATOR cout << "-----------------------------------------" << endl;

#ifdef LOCAL
	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
	#define cerr if(0)cout
#endif

const int maxn = 2e5+7;
const int inf = 1e9+7;
const LL LLinf = ((LL)1e18)+7LL;
const DBL pi = acos(-1.0);

// **************************************** CODE **************************************** //

LL n, k, maxi, cnt;

int32_t main() {
	speedup

	cin >> n >> k;
	VI a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	for (int i = 0; i < n; ++i) {
		if (a[i] > maxi) {maxi = a[i]; cnt = 1;}
		else cnt++;
		if (cnt == k) break;
	}

	cout << maxi;
}


#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define fren bigounce
#define speedup ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define usaco(in,out) ifstream cin(in); ofstream cout(out)
#define beg begin()
#define end end()
#define all(X) (X).beg, (X).end
#define sz(X) ((int)X.size())
#define sqr(x) (x*x)
#define erase_dupes(X) sort(all(X)); (X).resize(distance((X).begin(), unique(all(X))));
#define decimal(X) cout << fixed << setprecision(X)
#define mst(X,Y) memset(X,Y,sizeof(X));

typedef long long LL;
typedef double DBL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<string, int> PSI;
typedef pair<int,string> PIS;
typedef vector<PSI> VPSI;
typedef vector<PIS> VPIS;
typedef pair<char,int> PCI;
typedef pair<int,char> PIC;
typedef vector<PCI> VPCI;
typedef vector<PIC> VPIC;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;
typedef vector< VI > VVI;
typedef vector< VLL > VVLL;

template<class T> void amax(T & a, const T & b) { a = max(a, b); }
template<class T> void amin(T & a, const T & b) { a = min(a, b); }

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "{";
  for(int i=0;i<sz(V);++i) {if(i==sz(V)-1) os << V[i]; else os << V[i] << ",";}
  return os << "}";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.ff << "," << P.ss << ")";
}

template<class TH> void _dbg(const char *sdbg, TH h) {cerr<<sdbg<<" = "<<h<<endl;}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#define LOCAL
#define SEPERATOR cout << "-----------------------------------------" << endl;

#ifdef LOCAL
	#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
	#define cerr if(0)cout
#endif

const int maxn = 2e5+7;
const int inf = 1e9+7;
const LL LLinf = ((LL)1e18)+7LL;
const DBL pi = acos(-1.0);

// **************************************** CODE **************************************** //

LL n, k, maxi, cnt;

int32_t main() {
	speedup

	cin >> n >> k;
	VI a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];

	maxi = a[0];
	for (int i = 1; i < n; ++i) {
		if (a[i] > maxi) {maxi = a[i]; cnt = 1;}
		else cnt++;

		if (cnt == k) break;
	}

	cout << maxi;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pr pair<int,int>
#define mod 1000000007

void  solve()
{
    int n,k;
    cin>>n>>k;

    int a[n];

    for(int i=0; i<n; i++)
        cin>>a[i];

    if(k >= (n-1))
        cout<<n<<endl;
    else
    {

        for(int i=0; i<n; )
        {
            if(a[i] == n)
            {
                cout<<a[i]<<endl;
                return;
            }

            for(int j=i+1; j<n; j++)
            {
                if(a[j] > a[i])
                {
                    int curr = j-i-1;
                    if(curr >= k)
                    {
                        cout<<a[i]<<endl;
                        return;
                    }
                    else
                    {
                        i = j;
                        break;
                    }
                }
            }
        }
    }

    return;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pr pair<int,int>
#define mod 1000000007

void  solve()
{
    int n,k;
    cin>>n>>k;

    int a[n];

    for(int i=0; i<n; i++)
        cin>>a[i];

    if(k >= (n-1))
        cout<<n<<endl;
    else
    {

        for(int i=0; i<n; i++)
        {
            if(a[i] == n)
            {
                cout<<a[i]<<endl;
                return;
            }

            for(int j=i+1; j<n; j++)
            {
                if(a[j] > a[i])
                {
                    int curr = j-1;
                    if(curr >= k)
                    {
                        cout<<a[i]<<endl;
                        return;
                    }
                    else
                    {
                        i = j-1;
                        break;
                    }
                }
            }
        }
    }

    return;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pr pair<int,int>
#define mod 1000000007

void  solve()
{
    int n,k;
    cin>>n>>k;

    int a[n];

    for(int i=0; i<n; i++)
        cin>>a[i];

    if(k >= (n-1))
        cout<<n<<endl;
    else
    {

        map<int,int>mp;
        for(int i=0; i<n; i++)
        {
            if(a[i] == n)
            {
                cout<<a[i]<<endl;
                return;
            }

            for(int j=i+1; j<n; j++)
            {
                if(a[j] > a[i])
                {
                    if(mp[a[i]] >= k)
                    {
                        cout<<a[i]<<endl;
                        return;
                    }
                    else
                    {
                        mp[a[j]]++;
                        i = j-1;
                        break;
                    }
                }
                else
                    mp[a[i]]++;
            }
        }
    }

    return;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pr pair<int,int>
#define mod 1000000007

void  solve()
{
    int n,k;
    cin>>n>>k;

    int a[n];

    for(int i=0; i<n; i++)
        cin>>a[i];

    if(k >= (n-1))
        cout<<n<<endl;
    else
    {

        for(int i=0; i<n; i++)
        {
            if(a[i] == n)
            {
                cout<<a[i]<<" "<<endl;
                return;
            }

            for(int j=i+1; j<n; j++)
            {
                if(a[j] > a[i])
                {
                    int curr = j-i-1;
                    if(curr >= k)
                    {
                        cout<<a[i]<<" "<<endl;
                        return;
                    }
                }
            }
        }
    }

    return;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pr pair<int,int>
#define mod 1000000007

void  solve()
{
    int n,k;
    cin>>n>>k;

    int a[n];

    for(int i=0; i<n; i++)
        cin>>a[i];

    if(k >= (n-1))
        cout<<n<<endl;
    else
    {

        for(int i=0; i<n; i++)
        {
            if(a[i] == n)
            {
                cout<<a[i]<<endl;
                return;
            }

            for(int j=i+1; j<n; j++)
            {
                if(a[j] > a[i])
                {
                    int curr = j-i-1;
                    if(curr >= k)
                    {
                        cout<<a[i]<<endl;
                        return;
                    }
                    else
                        break;
                }
            }
        }
    }

    return;
}

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();
}


#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"
#define tab "\t"

const int MAXN=100100;

int main()
{
    ios::sync_with_stdio(0);
    int n, list[500];
    ll k;
    cin>>n>>k;
    int a, max = 0, pos_max = 0;
    int wins = 0, current_winner;
    forr(i,0,n)
    {
        cin>>a;
        if (max < a){
            max = a;
            pos_max = i;
        }
        list[i]=a;
    }
    if (pos_max < k || n < k)
        cout<<max;
    else
    {
        current_winner = list[0];
        wins = 0;
        forr(i, 1, n)
        {
            if (list[i] < current_winner)
                wins++;
            else
                {
                    current_winner =list[i];
                    wins = 0;
                }
            if (wins == k)
                cout<<current_winner;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"
#define tab "\t"

const int MAXN=100100;

int main()
{
    ios::sync_with_stdio(0);
    int n, list[500];
    ll k;
    cin>>n>>k;
    int a, max = 0, pos_max = 0;
    int wins = 0, current_winner;
    bool flag=true;
    forr(i,0,n)
    {
        cin>>a;
        if (max < a){
            max = a;
            pos_max = i;
        }
        list[i]=a;
    }
    if (pos_max < k || n < k)
        cout<<max;
    else
    {
        current_winner = list[0];
        wins = 0;
        forr(i, 1, n)
        {
            if (list[i] < current_winner)
                wins++;
            else
                {
                    current_winner =list[i];
                    wins = 1;
                }
            if (wins == k){
                cout<<current_winner;
                flag = false;
                break;}
        }
        if (flag)
            cout<<current_winner;
    }

}


#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"
#define tab "\t"

const int MAXN=100100;

int main()
{
    ios::sync_with_stdio(0);
    int n, list[500];
    ll k;
    cin>>n>>k;
    int a, max = 0, pos_max = 0;
    int wins = 0, current_winner;
    bool flag=true;
    forr(i,0,n)
    {
        cin>>a;
        if (max < a){
            max = a;
            pos_max = i;
        }
        list[i]=a;
    }
    if (pos_max < k || n < k)
        cout<<max;
    else
    {
        current_winner = list[0];
        wins = 0;
        forr(i, 1, n)
        {
            if (list[i] < current_winner)
                wins++;
            else
                {
                    current_winner =list[i];
                    wins = 0;
                }
            if (wins == k){
                cout<<current_winner;
                flag = false;
                break;}
        }
        if (flag)
            cout<<current_winner;
    }

}


#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"
#define tab "\t"

const int MAXN=100100;

int main()
{
    ios::sync_with_stdio(0);
    int n, list[500];
    ll k;
    cin>>n>>k;
    int a, max = 0, pos_max = 0;
    int wins = 0, current_winner;
    bool flag=true;
    forr(i,0,n)
    {
        cin>>a;
        if (max < a){
            max = a;
            pos_max = i;
        }
        list[i]=a;
    }
    if (pos_max < k || n < k)
        cout<<max;
    else
    {
        current_winner = list[0];
        wins = 0;
        forr(i, 1, n)
        {
            if (list[i] < current_winner)
                wins++;
            else
                {
                    current_winner =list[i];
                    wins = 0;
                }
            if (wins == k){
                cout<<current_winner;
                flag = false;}
        }
        if (flag)
            cout<<current_winner;
    }

}


#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"
#define tab "\t"

const int MAXN=100100;

int main()
{
    ios::sync_with_stdio(0);
    int n, list[500];
    ll k;
    cin>>n>>k;
    int a, max = 0, pos_max = 0;
    int wins = 0, current_winner;
    forr(i,0,n)
    {
        cin>>a;
        if (max < a){
            max = a;
            pos_max = i;
        }
        list[i]=a;
    }
    if (pos_max < k || n < k)
        cout<<max;
    else
    {
        current_winner = list[0];
        wins = 0;
        forr(i, 1, n)
        {
            if (list[i] < current_winner)
                wins++;
            else
                {
                    current_winner =list[i];
                    wins = 0;
                }
            if (wins == k)
                cout<<current_winner;
        }
        cout<<current_winner;
    }

}


#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"
#define tab "\t"

const int MAXN=100100;

int main()
{
    ios::sync_with_stdio(0);
    int n, list[500];
    ll k;
    cin>>n>>k;
    int a, max = 0, pos_max = 0;
    int wins = 0, current_winner;
    forr(i,0,n)
    {
        cin>>a;
        if (max < a){
            max = a;
            pos_max = i;
        }
        list[i]=a;
    }
    if (pos_max < k || n < k || pos_max == n-1)
        cout<<max;
    else
    {
        current_winner = list[0];
        wins = 0;
        forr(i, 1, n)
        {
            if (list[i] < current_winner)
                wins++;
            else
                {
                    current_winner =list[i];
                    wins = 0;
                }
            if (wins == k)
                cout<<current_winner;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define forn(i,n) forr(i,0,n)
#define sz(c) ((int)c.size())
#define zero(v) memset(v, 0, sizeof(v))
#define forall(it,v) for(auto it=v.begin();it!=v.end();++it)
#define pb push_back
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
#define dforn(i,n) for(int i=n-1; i>=0; i--)
#define dprint(v) cout << #v"=" << v << endl
#define endl "\n"
#define tab "\t"

const int MAXN=100100;

int main()
{
    ios::sync_with_stdio(0);
    int n, list[500];
    ll k;
    cin>>n>>k;
    int a, max = 0, pos_max = 0;
    int wins = 0, current_winner;
    forr(i,0,n)
    {
        cin>>a;
        if (max < a){
            max = a;
            pos_max = i;
        }
        list[i]=a;
    }
    if (pos_max < k || n < k)
        cout<<max;
    else
    {
        current_winner = list[0];
        wins = 0;
        forr(i, 1, n)
        {
            if (list[i] < current_winner)
                wins++;
            else
                {
                    current_winner =list[i];
                    wins = 0;
                }
            if (wins == k)
                cout<<current_winner;
        }

    }
    cout<<current_winner;

}


#include<bits/stdc++.h>
using namespace std;
pair<int, long long> a[510];

/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    //int i = 0, j;
    while(1)
    {
        if(a[0].first < a[1].first)
            swap(a[0], a[1]);
        a[0].second++;
        if(a[0].second == k)
            break;
        for(int i = n - 1; i > 1; i--)
            swap(a[1], a[i]);
    }
    cout << a[0].first;
    return 0;
}
*/

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    int i = 0;
    if(n == 2)
    {
        cout << max(a[0].first, a[1].first);
        return 0;
    }
    while(1)
    {
        if(a[0].first < a[i].first)
            swap(a[0], a[i]);
        a[0].second++;
        if(a[0].second == k)
            break;
        i = i % (n - 1) + 1;
    }
    cout << a[0].first;
    return 0;
}

/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    int m = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    cout << max(a[0].first, a[1].first) << endl;
    return 0;
}
*/


#include<bits/stdc++.h>
using namespace std;
pair<int, long long> a[510];
/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    while(1)
    {
        if(a[0].first < a[1].first)
            swap(a[0], a[1]);
        a[0].second++;
        //cout << a[0].second << endl;
        if(a[0].second == k)
            break;
        for(int i = n - 1; i > 1; i--)
            swap(a[1], a[i]);
    }
    cout << a[0].first;
    return 0;
}
*/

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    int m = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[0].first;
        m = max(a[0].first, m);
    }
    cout << m << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
pair<int, long long> a[510];

/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    //int i = 0, j;
    while(1)
    {
        if(a[0].first < a[1].first)
            swap(a[0], a[1]);
        a[0].second++;
        if(a[0].second == k)
            break;
        for(int i = n - 1; i > 1; i--)
            swap(a[1], a[i]);
    }
    cout << a[0].first;
    return 0;
}
*/

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    if(n == 2)
    {
        cout << max(a[0].first, a[1].first);
        return 0;
    }
    int i = 1;
    while(1)
    {
        if(a[0].first < a[i].first)
            swap(a[0], a[i]);
        a[0].second++;
        if(a[0].second == k)
            break;
        i = i % (n - 1) + 1;
    }
    cout << a[0].first;
    return 0;
}

/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    int m = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    cout << max(a[0].first, a[1].first) << endl;
    return 0;
}
*/


#include<bits/stdc++.h>
using namespace std;
pair<int, long long> a[510];
/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    while(1)
    {
        if(a[0].first < a[1].first)
            swap(a[0], a[1]);
        a[0].second++;
        //cout << a[0].second << endl;
        if(a[0].second == k)
            break;
        for(int i = n - 1; i > 1; i--)
            swap(a[1], a[i]);
    }
    cout << a[0].first;
    return 0;
}
*/

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    int m = 0;
    for(int i = 0; i < n; i++)
        cin >> a[0].first;
    cout << max(a[0].first, a[1].first) << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
pair<int, long long> a[510];

/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    //int i = 0, j;
    while(1)
    {
        if(a[0].first < a[1].first)
            swap(a[0], a[1]);
        a[0].second++;
        if(a[0].second == k)
            break;
        for(int i = n - 1; i > 1; i--)
            swap(a[1], a[i]);
    }
    cout << a[0].first;
    return 0;
}
*/

int main()
{
    int n, m = 0;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i].first;
        m = max(m, a[i].first);
    }
    int i = 1;
    while(1)
    {
        if(a[0].first < a[i].first)
            swap(a[0], a[i]);
        if(a[0].first == m)
            break;
        a[0].second++;
        if(a[0].second == k)
            break;
        i = i % (n - 1) + 1;
    }
    cout << a[0].first;
    return 0;
}

/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    int m = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    cout << max(a[0].first, a[1].first) << endl;
    return 0;
}
*/


#include<bits/stdc++.h>
using namespace std;
pair<int, long long> a[510];

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    while(1)
    {
        if(a[0].first < a[1].first)
            swap(a[0], a[1]);
        a[0].second++;
        //cout << a[0].second << endl;
        if(a[0].second == k)
            break;
        for(int i = n - 1; i > 1; i--)
            swap(a[1], a[i]);
    }
    cout << a[0].first;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
pair<int, long long> a[510];
/*
int main()
{
    int n;
    long long k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    while(1)
    {
        if(a[0].first < a[1].first)
            swap(a[0], a[1]);
        a[0].second++;
        //cout << a[0].second << endl;
        if(a[0].second == k)
            break;
        for(int i = n - 1; i > 1; i--)
            swap(a[1], a[i]);
    }
    cout << a[0].first;
    return 0;
}
*/

int main()
{
    int n;
    long long k;
    cin >> n >> k;
    int m = 0;
    for(int i = 0; i < n; i++)
        cin >> a[i].first;
    cout << max(a[0].first, a[1].first) << endl;
    return 0;
}


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Boss{
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        HashSet<Integer> hs=new HashSet<Integer>();
        int i;
        for(i=1;i<=n;i++){
            hs.add(i);
        }
        List<Integer> a=new ArrayList<Integer>();
        for(i=0;i<n;i++){
            a.add(0);
        }
        for(i=0;i<n;i++){
            int temp=scan.nextInt();
            if(hs.contains(temp)){
                a.set(i,temp);
                hs.remove(temp);
            }
        }
        Iterator hsi=hs.iterator();
        i=0;
        while(hsi.hasNext()){
            while(a.get(i)!=0){
                i+=1;
            }
            a.set(i,(int)hsi.next());
        }
        for(i=0;i<n;i++){
            System.out.print(a.get(i)+" ");
        }

    }
}


import java.util.*;
import java.io.*;
import java.io.File;
import java.util.AbstractSet;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.math.*;
public class Hello {

  //static FastReader in = new FastReader(System.in);
  public static void main(String[] args) {
    //try {
    //  FileInputStream fis = new FileInputStream("data.txt");
    //  System.setIn(fis);
      Scanner in = new Scanner(System.in);
      // Scanner in = new Scanner(new File("input.txt"));
      // PrintWriter out = new PrintWriter("output.txt");

      int n = in.nextInt();
      int []a = new int[n];
      int []b = new int[n];
      for (int i = 0;i < n;i++) a[i] = in.nextInt();
      for (int i = 0;i < n;i++) b[i] = -1;
      Map<Integer, Integer> mp = new HashMap();
      for (int i = 0;i < n;++i) {
	if (a[i] >= 1 && a[i] <= n) {
	  mp.put(a[i], i);
	}
      }

      for (Integer key:mp.keySet()) {
	b[mp.get(key)] = key;
      }
      int top = 0;
      for (int i = 1;i <= n;++i) {
	if (mp.containsKey(i)) continue;
	while (b[top] > 0) top++;
	b[top] = i;
      }

      for (int i = 0;i < n;++i) {
	System.out.print(b[i] + " ");
      }
      System.out.println();
    //} catch (FileNotFoundException e){
    //  System.out.println("error");
    //}
  }
///////////////////////
}
class FastReader {
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

    public FastReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1) {
            throw new InputMismatchException();
        }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0) {
                return -1;
            }
        }

        return buf[curChar++];
    }

    public int peek() {
        if (numChars == -1) {
            return -1;
        }
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                return -1;
            }
            if (numChars <= 0) {
                return -1;
            }
        }
        return buf[curChar];
    }

    public int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c == ',') {
                c = read();
            }
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    public boolean isSpaceChar(int c) {
        if (filter != null) {
            return filter.isSpaceChar(c);
        }
        return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0() {
        StringBuilder buf = new StringBuilder();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r') {
                buf.appendCodePoint(c);
            }
            c = read();
        }
        return buf.toString();
    }

    public String nextLine() {
        String s = readLine0();
        while (s.trim().length() == 0)
            s = readLine0();
        return s;
    }

    public String nextLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines) {
            return nextLine();
        } else {
            return readLine0();
        }
    }

    public BigInteger nextBigInteger() {
        try {
            return new BigInteger(nextString());
        } catch (NumberFormatException e) {
            throw new InputMismatchException();
        }
    }

    public char nextCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E') {
                return res * Math.pow(10, nextInt());
            }
            if (c < '0' || c > '9') {
                throw new InputMismatchException();
            }
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E') {
                    return res * Math.pow(10, nextInt());
                }
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted() {
        int value;
        while (isSpaceChar(value = peek()) && value != -1)
            read();
        return value == -1;
    }

    public String next() {
        return nextString();
    }

    public SpaceCharFilter getFilter() {
        return filter;
    }

    public void setFilter(SpaceCharFilter filter) {
        this.filter = filter;
    }

    public interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.Collectors;

public class B {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(reader.readLine());

        int[] arr = new int[n];
        int[] set = new int[(int)1e5+1];
        String[] split = reader.readLine().split(" ");
        int unique = 0;
        for(int i = 0; i < n; i++) {
            int val = Integer.parseInt(split[i]);
            arr[i] = val;
            set[val]++;
            if(set[val] == 1 && val >= 1 && val <= n) {
                unique++;
            }
        }
        final int nAvailable = n - unique;
        int[] available = new int[nAvailable];
        int av = 0;
        for(int i = 1; i <= n; i++) {
            if(set[i] == 0) {
                available[av++] = i;
            }
        }

        av = 0;
        for(int i = 0; i < arr.length; i++) {
            int val = arr[i];
            if(set[val] > 1 || val < 1 || val > n) {
               arr[i] = available[av++];
               set[val]--;
            }
        }
        String collect = Arrays.stream(arr).mapToObj(String::valueOf).collect(Collectors.joining(" "));
        System.out.println(collect);
    }
}


import java.io.BufferedOutputStream;
import java.io.Closeable;
import java.io.DataInputStream;
import java.io.Flushable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.TreeSet;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	static class TaskAdapter implements Runnable {
		@Override
		public void run() {
			long startTime = System.currentTimeMillis();
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			FastReader in = new FastReader(inputStream);
			Output out = new Output(outputStream);
			BInventory solver = new BInventory();
			solver.solve(1, in, out);
			out.close();
			System.err.println(System.currentTimeMillis()-startTime+"ms");
		}
	}

	public static void main(String[] args) throws Exception {
		Thread thread = new Thread(null, new TaskAdapter(), "", 1<<28);
		thread.start();
		thread.join();
	}

	static class BInventory {
		public BInventory() {
		}

		public void solve(int kase, InputReader in, Output pw) {
			int n = in.nextInt();
			TreeSet<Integer> left = new TreeSet<>();
			for(int i = 1; i<=n; i++) {
				left.add(i);
			}
			int[] ans = new int[n];
			ArrayList<Integer> toadd = new ArrayList<>(n);
			for(int i = 0; i<n; i++) {
				int x = in.nextInt();
				if(left.contains(x)) {
					left.remove(x);
					ans[i] = x;
				}else {
					toadd.add(i);
				}
			}
			for(int i: toadd) {
				ans[i] = left.pollFirst();
			}
			pw.println(ans);
		}

	}

	static class Output implements Closeable, Flushable {
		public StringBuilder sb;
		public OutputStream os;
		public int BUFFER_SIZE;
		public String lineSeparator;

		public Output(OutputStream os) {
			this(os, 1<<16);
		}

		public Output(OutputStream os, int bs) {
			BUFFER_SIZE = bs;
			sb = new StringBuilder(BUFFER_SIZE);
			this.os = new BufferedOutputStream(os, 1<<17);
			lineSeparator = System.lineSeparator();
		}

		public void print(int i) {
			print(String.valueOf(i));
		}

		public void print(String s) {
			sb.append(s);
			if(sb.length()>BUFFER_SIZE >> 1) {
				flushToBuffer();
			}
		}

		public void println() {
			sb.append(lineSeparator);
		}

		public void println(int[] arr) {
			for(int i = 0; i<arr.length; i++) {
				if(i!=0) {
					print(" ");
				}
				print(arr[i]);
			}
			println();
		}

		private void flushToBuffer() {
			try {
				os.write(sb.toString().getBytes());
			}catch(IOException e) {
				e.printStackTrace();
			}
			sb = new StringBuilder(BUFFER_SIZE);
		}

		public void flush() {
			try {
				flushToBuffer();
				os.flush();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public void close() {
			flush();
			try {
				os.close();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

	}

	static interface InputReader {
		int nextInt();

	}

	static class FastReader implements InputReader {
		final private int BUFFER_SIZE = 1<<16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer;
		private int bytesRead;

		public FastReader(InputStream is) {
			din = new DataInputStream(is);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public int nextInt() {
			int ret = 0;
			byte c = skipToDigit();
			boolean neg = (c=='-');
			if(neg) {
				c = read();
			}
			do {
				ret = ret*10+c-'0';
			} while((c = read())>='0'&&c<='9');
			if(neg) {
				return -ret;
			}
			return ret;
		}

		private boolean isDigit(byte b) {
			return b>='0'&&b<='9';
		}

		private byte skipToDigit() {
			byte ret;
			while(!isDigit(ret = read())&&ret!='-') ;
			return ret;
		}

		private void fillBuffer() {
			try {
				bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			}catch(IOException e) {
				e.printStackTrace();
				throw new InputMismatchException();
			}
			if(bytesRead==-1) {
				buffer[0] = -1;
			}
		}

		private byte read() {
			if(bytesRead==-1) {
				throw new InputMismatchException();
			}else if(bufferPointer==bytesRead) {
				fillBuffer();
			}
			return buffer[bufferPointer++];
		}

	}
}


import java.util.*;
import java.lang.*;
import java.io.*;

public class inv
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++){
		    arr[i]=sc.nextInt();
		}
		List<Integer> un=new ArrayList<>();
		int[] cnt=new int[100006];
		for(int i=0;i<n;i++){
		    cnt[arr[i]]++;
		}
		for(int i=1;i<100006;i++){
		    if(cnt[i]==0)
		    un.add(i);

		}
		int j=0;
		Map<Integer,Integer> hm=new HashMap<>();
		for(int i=0;i<n;i++){
		    hm.put(arr[i],hm.getOrDefault(arr[i],0)+1);
		    if(hm.get(arr[i])>1 || arr[i]>n){
		        arr[i]=un.get(j++);
		    }
		}
		for(int i:arr){
		    System.out.print(i+" ");
		}
		    System.out.println();

	}
}


import java.math.BigInteger;
import java.util.*;
import java.io.*;

public class solution {
    public static void merge(int arr[], int l, int m, int r) {
        // Find sizes of two subarrays to be merged
        int n1 = m - l + 1;
        int n2 = r - m;

        /* Create temp arrays */
        int L[] = new int[n1];
        int R[] = new int[n2];

        /*Copy data to temp arrays*/
        for (int i = 0; i < n1; ++i)
            L[i] = arr[l + i];
        for (int j = 0; j < n2; ++j)
            R[j] = arr[m + 1 + j];

        /* Merge the temp arrays */

        // Initial indexes of first and second subarrays
        int i = 0, j = 0;

        // Initial index of merged subarry array
        int k = l;
        while (i < n1 && j < n2) {
            if (L[i] <= R[j]) {
                arr[k] = L[i];
                i++;
            } else {
                arr[k] = R[j];
                j++;
            }
            k++;
        }

        /* Copy remaining elements of L[] if any */
        while (i < n1) {
            arr[k] = L[i];
            i++;
            k++;
        }

        /* Copy remaining elements of R[] if any */
        while (j < n2) {
            arr[k] = R[j];
            j++;
            k++;
        }
    }

    // Main function that sorts arr[l..r] using
    // merge()
    public static void sort(int arr[], int l, int r) {
        if (l < r) {
            // Find the middle point
            int m = (l + r) / 2;

            // Sort first and second halves
            sort(arr, l, m);
            sort(arr, m + 1, r);

            // Merge the sorted halves
            merge(arr, l, m, r);
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        } else return gcd(b, a % b);
    }

    static class pair {
        int x;
        int y;

        public pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static long lcm(long a, long b) {
        long v = a * b;
        long u = gcd(a, b);
        return v / u;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
       TreeSet<Integer>H = new TreeSet<>();
       for(int i=1;i<=n;i++){
           H.add(i);
       }
       int a[] = new int[n];
       StringTokenizer st = new StringTokenizer(br.readLine());
       for(int i=0;i<n;i++){
           a[i] = Integer.parseInt(st.nextToken());
           if(H.contains(a[i])){
               H.remove(a[i]);
           }
       }
       HashSet<Integer>H1 = new HashSet<>();
       for(int i=0;i<n;i++){
           if(H1.contains(a[i]) || a[i]>n){
               a[i] = H.first();
               H.remove(H.first());
           }
           H1.add(a[i]);
       }
       for(int i=0;i<n;i++){
           System.out.print(a[i] + " ");
       }
        System.out.println();
    }

    static class sort implements Comparator<ArrayList<Integer>> {

        @Override
        public int compare(ArrayList<Integer> o1, ArrayList<Integer> o2) {
            int c = o2.get(1).compareTo(o1.get(1));
            if(c == 0){
                c = o2.get(0).compareTo(o1.get(0));
            }
            return c;
        }

    }
}


import java.util.Scanner;
import java.util.Set;
import java.util.Vector;
import java.util.HashSet;
public class codeforces569B
{
  public static void main(String args[])
  {
      Scanner s = new Scanner(System.in);
      int n=s.nextInt(),i,k;
      int[] a = new int[n];
      int[] b = new int[n+1];
      Set<Integer> set = new HashSet<>();
      Vector<Integer> v1 = new Vector<>();
      Vector<Integer> v2 = new Vector<>();
      for(i=0;i<n;i++)
      {
          a[i]=s.nextInt();
          if(a[i]<n)
          b[a[i]]=1;
          if(set.contains(a[i])||a[i]>n)
          v1.add(i);
          else
          set.add(a[i]);
      }
      for(i=1;i<=n;i++)
      {
          if(b[i]==0)
          v2.add(i);
      }
      k=v1.size();
      for(i=0;i<k;i++)
      a[v1.remove(0)]=v2.remove(0);
      for(i=0;i<n;i++)
      System.out.print(a[i]+" ");
  }
}


import java.util.Scanner;
import java.util.TreeSet;
public class codeforces569B
{
  public static void main(String args[])
  {
      Scanner s = new Scanner(System.in);
      int n=s.nextInt(),i;
      int[] a = new int[n];
      TreeSet<Integer> set1 = new TreeSet<>();
      TreeSet<Integer> set2 = new TreeSet<>();
      for(i=0;i<n;i++)
      set1.add(i+1);
      for(i=0;i<n;i++)
      {
          a[i]=s.nextInt();
          set1.remove(a[i]);
      }
      for(i=0;i<n;i++)
      {
          if(set2.contains(a[i])||a[i]>n)
          {
              a[i]=set1.first();
              set1.remove(set1.first());
          }
          set2.add(a[i]);
      }
      for(i=0;i<n;i++)
      System.out.print(a[i]+" ");
  }
}


import java.util.Scanner;
import java.util.Vector;
import java.util.TreeSet;
public class codeforces569B
{
  public static void main(String args[])
  {
      Scanner s = new Scanner(System.in);
      int n=s.nextInt(),i,k;
      int[] a = new int[n];
      int[] b = new int[n+1];
      TreeSet<Integer> set = new TreeSet<>();
      Vector<Integer> v1 = new Vector<>();
      Vector<Integer> v2 = new Vector<>();
      for(i=0;i<n;i++)
      {
          a[i]=s.nextInt();
          if(a[i]<n)
          b[a[i]]=1;
          if(set.contains(a[i])||a[i]>n)
          v1.add(i);
          else
          set.add(a[i]);
      }
      for(i=1;i<=n;i++)
      {
          if(b[i]==0)
          v2.add(i);
      }
      k=v1.size();
      for(i=0;i<k;i++)
      a[v1.remove(0)]=v2.remove(0);
      for(i=0;i<n;i++)
      System.out.print(a[i]+" ");
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Vector;
import java.util.HashSet;
import java.util.StringTokenizer;
public class B569
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;
		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt()
		{
			return Integer.parseInt(next());
		}
		long nextLong()
		{
			return Long.parseLong(next());
		}
		double nextDouble()
		{
			return Double.parseDouble(next());
		}
		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
  public static void main(String args[])
  {
      FastReader s = new FastReader();
      StringBuilder sb = new StringBuilder();
      int n=s.nextInt(),i,k;
      int[] a = new int[n];
      int[] b = new int[n+1];
      HashSet<Integer> set = new HashSet<>();
      Vector<Integer> v1 = new Vector<>();
      Vector<Integer> v2 = new Vector<>();
      for(i=0;i<n;i++)
      {
          a[i]=s.nextInt();
          if(a[i]<n)
          b[a[i]]=1;
          if(set.contains(a[i])||a[i]>n)
          v1.add(i);
          else
          set.add(a[i]);
      }
      for(i=1;i<=n;i++)
      {
          if(b[i]==0)
          v2.add(i);
      }
      k=v1.size();
      for(i=0;i<k;i++)
      a[v1.remove(0)]=v2.remove(0);
      for(i=0;i<n;i++)
      sb.append(a[i]+" ");
      System.out.print(sb);
  }
}


import java.util.Scanner;
import java.util.TreeSet;
public class codeforces569B
{
  public static void main(String args[])
  {
      Scanner s = new Scanner(System.in);
      StringBuilder sb = new StringBuilder();
      int n=s.nextInt(),i;
      int[] a = new int[n];
      TreeSet<Integer> set1 = new TreeSet<>();
      TreeSet<Integer> set2 = new TreeSet<>();
      for(i=0;i<n;i++)
      set1.add(i+1);
      for(i=0;i<n;i++)
      {
          a[i]=s.nextInt();
          set1.remove(a[i]);
      }
      for(i=0;i<n;i++)
      {
          if(set2.contains(a[i])||a[i]>n)
          {
              a[i]=set1.first();
              set1.remove(set1.first());
          }
          set2.add(a[i]);
      }
      for(i=0;i<n;i++)
      sb.append(a[i]+" ");
      System.out.print(sb);
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.StringTokenizer;
public class B569
{
    static class FastReader
	{
		BufferedReader br;
		StringTokenizer st;
		public FastReader()
		{
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next()
		{
			while (st == null || !st.hasMoreElements())
			{
				try
				{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e)
				{
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt()
		{
			return Integer.parseInt(next());
		}
		long nextLong()
		{
			return Long.parseLong(next());
		}
		double nextDouble()
		{
			return Double.parseDouble(next());
		}
		String nextLine()
		{
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
	}
  public static void main(String args[])
  {
      FastReader s = new FastReader();
      StringBuilder sb = new StringBuilder();
      int n=s.nextInt(),i;
      int[] a = new int[n];
      TreeSet<Integer> set1 = new TreeSet<>();
      TreeSet<Integer> set2 = new TreeSet<>();
      for(i=0;i<n;i++)
      set1.add(i+1);
      for(i=0;i<n;i++)
      {
          a[i]=s.nextInt();
          set1.remove(a[i]);
      }
      for(i=0;i<n;i++)
      {
          if(set2.contains(a[i])||a[i]>n)
          {
              a[i]=set1.first();
              set1.remove(set1.first());
          }
          set2.add(a[i]);
      }
      for(i=0;i<n;i++)
      sb.append(a[i]+" ");
      System.out.print(sb);
  }
}


import java.io.OutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.util.Arrays;
    import java.util.Vector;
    import java.util.StringTokenizer;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.InputStream;
import java.util.HashMap;
import java.util.TreeSet;

/**
 *
 * @author Mohammed Reda
 */
public class Inventory {

        public static void main(String[] args) {
                InputStream inputStream = System.in;
                OutputStream outputStream = System.out;
                InputReader in = new InputReader(inputStream);
                PrintWriter out = new PrintWriter(outputStream);
                TaskA solver = new TaskA();
                solver.solve(1, in, out);
                out.close();
            }

            static class TaskA {
                public void solve(int testNumber, InputReader in, PrintWriter out) {
                int n= in.nextInt();
                int arr [] = new int [n] ;
 HashMap<Integer, Integer> hmap = new HashMap<Integer, Integer>();

                TreeSet t = new TreeSet();
                for (int i =0;i<n;i++){
                    int k = in.nextInt();
                if (k<=n){
                    t.add(k);
                    arr[i]=k;
hmap.put(k, 1);

                }

                }
               // System.out.println(hmap);
                int counter =1;
                for (int i =0;i<n;i++){

                int  k = arr[i];
                if (hmap.containsKey(k) && hmap.get(k)>0){
                hmap.put(k, 0);
                out.println(k);
                 //   System.out.println(hmap);
                   // System.out.println(t);
                } else { while (true){
                if (t.contains(counter)){
                counter++;
                } else {
                    t.add(counter);
                out.println(counter);
                break;
                }

                }

                }

                }

              //  out.println(t);
               // out.println(Arrays.toString(arr));

                }

                }

            static class InputReader {
                public BufferedReader reader;
                public StringTokenizer tokenizer;

                public InputReader(InputStream stream) {
                    reader = new BufferedReader(new InputStreamReader(stream), 32768);
                    tokenizer = null;
                }

                public String next() {
                    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                        try {
                            tokenizer = new StringTokenizer(reader.readLine());
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                    }
                    return tokenizer.nextToken();
                }

                public int nextInt() {
                    return Integer.parseInt(next());
                }

                public long nextLong() {
                    return Long.parseLong(next());
                }

            }
        }


#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n, m, k, a[N], cnt[N];
vector<int> thua;

int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
        if (a[i] > n || cnt[a[i]] > 1)
            thua.push_back(i);
    }
    //xu ly cac truong hop so xuat hien lap lai nhieu lan hoac lon hon n
    int id = 1;
    for (auto x : thua)
    {
        while (cnt[id] >= 1)
            id++;
        a[x] = id++;
    }
    //print result
    for (int i = 1; i <= n; i++)
        cout << a[i] << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n, m, k, a[N], cnt[N];
vector<int> lap;

int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
        if (a[i] > n || cnt[a[i]] > 1)
            lap.push_back(i);
    }
    //xu ly cac truong hop so xuat hien lap lai nhieu lan hoac lon hon n
    int id = 1;
    for (auto x : lap)
    {
        while (cnt[id] >= 1)
            id++;
        a[x] = id++;
        cnt[a[x]]++;
    }
    //print result
    for (int i = 1; i <= n; i++)
        cout << a[i] << " ";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int n, m, k, a[N], vis[N];

int main()
{
    ios::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int id = 1;
    for (int i = 1; i <= n; i++)
    {
        if (vis[a[i]] == 0)
            vis[a[i]] = 1;
        else
        {
            while (vis[id] == 1)
                id++;
            a[i] = id;
            vis[id] = 1;
        }
    }
    for (int i = 1; i <= n; i++)
        cout << a[i] << " ";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define  fast()      ios :: sync_with_stdio(false); cin.tie(0);
#define  ll             long long int
#define  ull            unsigned long long int
#define     sz(x)       (int)x.size()
#define  ld             long double
#define  vi             vector<int>
#define vl              vector<long long>
#define vc              vector<char>
#define vs              vector<string>
#define vp              vector< pair<ll,ll> >
#define sl              set<long long>
#define sc              set<char>
#define sts             stack<string>
#define max_3(a,b,c)    max(a, max(b,c))
#define max_4(a,b,c,d)  max(a,max(b,max(c,d)))
#define min_3(a,b,c)    min(a, min(b,c))
#define min_4(a,b,c,d)  min(a,min(b,min(c,d)))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define pi              2*acos(0.0)
#define N               100006
#define in              1234567890;
ll n,i,t,j=0,x,y,k,c=0,b[N];
int main()
{
    fast()
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    cin>>n;
    ll a[n+5];
    for(i=1;i<=n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    vl v;
    for(i=1;i<=n;i++) if(b[i]==0) v.push_back(i);
    for(i=1;i<=n;i++){
        if(b[a[i]]==1 && a[i]<=n) cout<<a[i];
        else {b[a[i]]--; cout<<v[c++];}
        cout<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
#define  fast()      ios :: sync_with_stdio(false); cin.tie(0);
#define  ll             long long int
#define  ull            unsigned long long int
#define     sz(x)       (int)x.size()
#define  ld             long double
#define  vi             vector<int>
#define vl              vector<long long>
#define vc              vector<char>
#define vs              vector<string>
#define vp              vector< pair<ll,ll> >
#define sl              set<long long>
#define sc              set<char>
#define sts             stack<string>
#define max_3(a,b,c)    max(a, max(b,c))
#define max_4(a,b,c,d)  max(a,max(b,max(c,d)))
#define min_3(a,b,c)    min(a, min(b,c))
#define min_4(a,b,c,d)  min(a,min(b,min(c,d)))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define pi              2*acos(0.0)
#define N               100006
#define in              1234567890;
int main()
{
    fast()
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    ll n,i,t,j=0,x,y,k,c=0;
    cin>>n;
    ll a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=1;i<=n;i++) cout<<i<<" ";
}


#include<bits/stdc++.h>
using namespace std;
#define  fast()      ios :: sync_with_stdio(false); cin.tie(0);
#define  ll             long long int
#define  ull            unsigned long long int
#define     sz(x)       (int)x.size()
#define  ld             long double
#define  vi             vector<int>
#define vl              vector<long long>
#define vc              vector<char>
#define vs              vector<string>
#define vp              vector< pair<ll,ll> >
#define sl              set<long long>
#define sc              set<char>
#define sts             stack<string>
#define max_3(a,b,c)    max(a, max(b,c))
#define max_4(a,b,c,d)  max(a,max(b,max(c,d)))
#define min_3(a,b,c)    min(a, min(b,c))
#define min_4(a,b,c,d)  min(a,min(b,min(c,d)))
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*b)/gcd(a,b)
#define pi              2*acos(0.0)
#define N               100006
#define in              1234567890;
int main()
{
    fast()
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    ll n,i,t,j=0,x,y,k,c=0;
    cin>>n;
    ll a[n+1],b[n+1]={0};
    vl v;
    for(i=1;i<=n;i++) cin>>a[i],b[a[i]]++;
    for(i=1;i<=n;i++){
        if(b[i]==0) v.push_back(i);
    }
    for(i=1;i<=n;i++){
        if(b[i]==1&&a[i]<=n) cout<<a[i];
        else {b[a[i]]--,cout<<v[c++];}
        cout<<" ";
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    int f[n+1]={0};
    for(int i=0;i< n;i++)
    {
        cin >>a[i];
        if(f[a[i]]!=0)
        {
            for (intj=1;j<n+1;j++)
            {
                if(f[j]==0) {
                    a[i]=j;
                    f[a[i]]++ ;
                    j=n+2;
                }
            }
        } else
            f[a[i]]++ ;
    }

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


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int a[n];
    int f[n+1]={0};
    for(int i=0;i< n;i++)
    {
        cin >>a[i];
        if(f[a[i]]!=0)
        {
            for (int j=1;j<n+1;j++)
            {
                if(f[j]==0) {
                    a[i]=j;
                    f[a[i]]++ ;
                    j=n+2;
                }
            }
        } else
            f[a[i]]++ ;
    }

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


#include <iostream>
#include <ctime>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <cassert>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int long long

//const int mod=1e9+7;
//const int inf=1e9+239+1329;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    vector <int> a(n);
    for(auto &t:a) cin >> t;
    vector <int> used(n+1);
	vector <int> ans(n,-1);
	for(int i=0;i<n;i++){
		int t=a[i];
		if(t>=1 && t<=n && !used[t]){
			ans[i]=t;
		}
		if(t>=1 && t<=n) used[t]=1;
 	}
 	vector <int> nu;
 	for(int i=1;i<=n;i++){
 		if(!used[i]) nu.push_back(i);
 	}
 	reverse(nu.begin(), nu.end());
 	for(auto &t:ans){
 		if(t==-1){
 			t=nu.back();
 			nu.pop_back();
 		}
 	}
 	for(auto t:ans){
 		cout << t << " ";
 	}
 	cout << endl;

}


#include <iostream>
#include <ctime>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <cassert>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int long long

//const int mod=1e9+7;
//const int inf=1e9+239+1329;

int get_new(vector <int> &used,int ws){
	for(int i=ws;i<used.size();i++){
		if(!used[i]) return i;
	}
	return -1;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    vector <int> a(n);
    for(auto &t:a) cin >> t;
    vector <int> used(n+1);
	int l=1;
	for(auto &t:a){

		if(!used[t] && t>=1 && t<=n){
			used[t]=true;
			l=get_new(used,l);
			continue;
		}
		else{
			t=l;
			used[l]=true;
			l=get_new(used,l);
		}
 	}
 	for(auto &r:a) cout << r << " ";
 	cout << endl;
}


#include <iostream>
#include <ctime>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <stack>
#include <cassert>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int long long

//const int mod=1e9+7;
//const int inf=1e9+239+1329;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;
    vector <int> a(n);
    for(auto &t:a) cin >> t;
    vector <int> used(n+1);
	vector <int> ans(n,-1);
	for(int i=0;i<n;i++){
		int t=a[i];
		if(t>=1 && t<=n && !used[t]){
			ans[i]=t;
		}
		used[t]=1;
 	}
 	vector <int> nu;
 	for(int i=1;i<=n;i++){
 		if(!used[i]) nu.push_back(i);
 	}
 	reverse(nu.begin(), nu.end());
 	for(auto &t:ans){
 		if(t==-1){
 			t=nu.back();
 			nu.pop_back();
 		}
 	}
 	for(auto t:ans){
 		cout << t << " ";
 	}
 	cout << endl;

}


#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    long long int n,i;
    cin>>n;
    long int a[n+1]={0},b[n],c[n],l=0;
    for(i=0;i<n;i++){
        cin>>b[i];
        a[b[i]]+=1;
    }
    for(i=1;i<=n;i++){
        if(a[i]==0){
            c[l]=i;
            l+=1;
        }
    }
    l=0;
    for(i=0;i<n;i++){
        if(a[b[i]]>1){
            cout<<c[l]<<" ";
            a[b[i]]-=1;
            l+=1;
        }
        else
            cout<<b[i]<<" ";
    }
}


#include <bits/stdc++.h>
/*
 * TILL I COLLAPSE
 */
using namespace std;
#define ll               long long
#define ld               long double
#define all(v)           ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define rep(i, v)        for(int i=0;i<sz(v);i++)
#define lp(i, n)         for(int i=0;i<(int)(n);i++)
#define lp1(i, n)        for(int i=1;i<=(int)(n);i++)
#define loop(i, num, n)  for(int i=num;i<(int)n;i++)
#define vi               vector <int>
#define vl               vector <ll>
#define vpi              vector<pair<int,int>>
#define vpll             vector<pair<ll,ll>>
#define vstr             vector<string>
#define pb               push_back
#define mp               make_pair
#define yes              cout << "YES" << endl
#define no               cout << "NO" << endl
#define out(x)           cout << (x) << endl
#define in(x)            cin >> (x)
const int INF = INT_MAX;
const int MAX = 200005;

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

void printvi(vi arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

void printvll(vl arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

void solve() {
    int n;
    in(n);
    vi arr(n);
    vi freq(n + 1, 0);
    lp(i, n) {
        int x;
        in(x);
        freq[x]++;
        arr[i] = x;
    }
    vi flag;
    for (int i = 1; i <= n; i++) {
        if (freq[i] == 0) {
            flag.pb(i);
        }
    }
    //printvi(freq);
    //printvi(flag);
    int i = 0;
    while (!flag.empty()) {
        if (freq[arr[i]] > 1) {
            freq[arr[i]]--;
            freq[flag[0]]++;
            arr[i] = flag[0];
            flag.erase(flag.begin());
        }
        i++;
    }
    printvi(arr);

}

int main() {
    //freopen("jumping.in", "r", stdin);
    run();
    solve();
    return 0;
}


#include <bits/stdc++.h>
/*
 * TILL I COLLAPSE
 */
using namespace std;
#define ll               long long
#define ld               long double
#define all(v)           ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define rep(i, v)        for(int i=0;i<sz(v);i++)
#define lp(i, n)         for(int i=0;i<(int)(n);i++)
#define lp1(i, n)        for(int i=1;i<=(int)(n);i++)
#define loop(i, num, n)  for(int i=num;i<(int)n;i++)
#define vi               vector <int>
#define vl               vector <ll>
#define vpi              vector<pair<int,int>>
#define vpll             vector<pair<ll,ll>>
#define vstr             vector<string>
#define pb               push_back
#define mp               make_pair
#define yes              cout << "YES" << endl
#define no               cout << "NO" << endl
#define out(x)           cout << (x) << endl
#define in(x)            cin >> (x)
const int INF = INT_MAX;
const int MAX = 200005;

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

void printvi(vi arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

void printvll(vl arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

void solve() {
    int n;
    in(n);
    vi arr(n);
    vi freq(100000 + 1, 0);
    lp(i, n) {
        int x;
        in(x);
        freq[x]++;
        arr[i] = x;
    }
    if(n==1){
        if(arr[0]==n)
            printvi(arr);
        else{
            arr[0]=n;
            printvi(arr);
        }
    }
    else {
        vi flag;
        for (int i = 1; i <= n; i++) {
            if (freq[i] == 0) {
                flag.pb(i);
            }
        }
        //printvi(freq);
        //printvi(flag);
        int i = 0;
        while (!flag.empty()) {
            if(arr[i]>n){
                freq[flag[0]]++;
                arr[i] = flag[0];
                flag.erase(flag.begin());
            }
            else if (freq[arr[i]] > 1) {
                freq[arr[i]]--;
                freq[flag[0]]++;
                arr[i] = flag[0];
                flag.erase(flag.begin());
            }
            i++;
        }
        printvi(arr);
    }

}

int main() {
    //freopen("jumping.in", "r", stdin);
    run();
    solve();
    return 0;
}


#include <bits/stdc++.h>
/*
 * TILL I COLLAPSE
 */
using namespace std;
#define ll               long long
#define ld               long double
#define all(v)           ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define rep(i, v)        for(int i=0;i<sz(v);i++)
#define lp(i, n)         for(int i=0;i<(int)(n);i++)
#define lp1(i, n)        for(int i=1;i<=(int)(n);i++)
#define loop(i, num, n)  for(int i=num;i<(int)n;i++)
#define vi               vector <int>
#define vl               vector <ll>
#define vpi              vector<pair<int,int>>
#define vpll             vector<pair<ll,ll>>
#define vstr             vector<string>
#define pb               push_back
#define mp               make_pair
#define yes              cout << "YES" << endl
#define no               cout << "NO" << endl
#define out(x)           cout << (x) << endl
#define in(x)            cin >> (x)
const int INF = INT_MAX;
const int MAX = 200005;

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

void printvi(vi arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

void printvll(vl arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

void solve() {
    int n;
    in(n);
    vi arr(n);
    vi freq(100000 + 1, 0);
    lp(i, n) {
        int x;
        in(x);
        freq[x]++;
        arr[i] = x;
    }
    if (n == 1) {
        if (arr[0] == n)
            printvi(arr);
        else {
            arr[0] = n;
            printvi(arr);
        }
    } else {
        vi flag;
        for (int i = 1; i <= n; i++) {
            if (freq[i] == 0) {
                flag.pb(i);
            }
        }
        //printvi(freq);
        //printvi(flag);
        int i = 0;
        while (!flag.empty()) {
            if (arr[i] > n) {
                freq[flag[0]]++;
                arr[i] = flag[0];
                flag.erase(flag.begin());
            } else if (freq[arr[i]] > 1) {
                freq[arr[i]]--;
                freq[flag[0]]++;
                arr[i] = flag[0];
                flag.erase(flag.begin());
            }
            i++;
        }
        printvi(arr);
    }

}

int main() {
    //freopen("jumping.in", "r", stdin);
    run();
    solve();
    return 0;
}


#include <bits/stdc++.h>
/*
 * TILL I COLLAPSE
 */
using namespace std;
#define ll               long long
#define ld               long double
#define all(v)           ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define rep(i, v)        for(int i=0;i<sz(v);i++)
#define lp(i, n)         for(int i=0;i<(int)(n);i++)
#define lp1(i, n)        for(int i=1;i<=(int)(n);i++)
#define loop(i, num, n)  for(int i=num;i<(int)n;i++)
#define vi               vector <int>
#define vl               vector <ll>
#define vpi              vector<pair<int,int>>
#define vpll             vector<pair<ll,ll>>
#define vstr             vector<string>
#define pb               push_back
#define mp               make_pair
#define yes              cout << "YES" << endl
#define no               cout << "NO" << endl
#define out(x)           cout << (x) << endl
#define in(x)            cin >> (x)
const int INF = INT_MAX;
const int MAX = 200005;

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

void printvi(vi arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

void printvll(vl arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

void solve() {
    int n;
    in(n);
    vpi arr(n);
    vi flag(n);
    lp(i, n) {
        int x;
        in(x);
        arr[i].first = x;
        arr[i].second = i;
    }
    lp(i, n) flag[i] = i + 1;
    sort(all(arr));
    lp(i, n) {
        if (arr[i].first != flag[i]) {
            arr[i].first = flag[i];
        }
    }
    sort(all(arr), sortbysec);
    lp(i, n) cout << arr[i].first << " ";
    cout << endl;

}

int main() {
    //freopen("jumping.in", "r", stdin);
    run();
    solve();
    return 0;
}


#include <bits/stdc++.h>
/*
 * TILL I COLLAPSE
 */
using namespace std;
#define ll               long long
#define ld               long double
#define all(v)           ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define rep(i, v)        for(int i=0;i<sz(v);i++)
#define lp(i, n)         for(int i=0;i<(int)(n);i++)
#define lp1(i, n)        for(int i=1;i<=(int)(n);i++)
#define loop(i, num, n)  for(int i=num;i<(int)n;i++)
#define vi               vector <int>
#define vl               vector <ll>
#define vpi              vector<pair<int,int>>
#define vpll             vector<pair<ll,ll>>
#define vstr             vector<string>
#define pb               push_back
#define mp               make_pair
#define yes              cout << "YES" << endl
#define no               cout << "NO" << endl
#define out(x)           cout << (x) << endl
#define in(x)            cin >> (x)
const int INF = INT_MAX;
const int MAX = 200005;

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

void printvi(vi arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

void printvll(vl arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

void solve() {
    int n;
    in(n);
    vi arr(n);
    vi freq(n + 1, 0);
    lp(i, n) {
        int x;
        in(x);
        freq[x]++;
        arr[i] = x;
    }
    if(n==1){
        if(arr[0]==n)
            printvi(arr);
        else{
            arr[0]=n;
            printvi(arr);
        }
    }
    else {
        vi flag;
        for (int i = 1; i <= n; i++) {
            if (freq[i] == 0) {
                flag.pb(i);
            }
        }
        //printvi(freq);
        //printvi(flag);
        int i = 0;
        while (!flag.empty()) {
            if (freq[arr[i]] > 1) {
                freq[arr[i]]--;
                freq[flag[0]]++;
                arr[i] = flag[0];
                flag.erase(flag.begin());
            }
            i++;
        }
        printvi(arr);
    }

}

int main() {
    //freopen("jumping.in", "r", stdin);
    run();
    solve();
    return 0;
}


#include <bits/stdc++.h>
/*
 * TILL I COLLAPSE
 */
using namespace std;
#define ll               long long
#define ld               long double
#define all(v)           ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define rep(i, v)        for(int i=0;i<sz(v);i++)
#define lp(i, n)         for(int i=0;i<(int)(n);i++)
#define lp1(i, n)        for(int i=1;i<=(int)(n);i++)
#define loop(i, num, n)  for(int i=num;i<(int)n;i++)
#define vi               vector <int>
#define vl               vector <ll>
#define vpi              vector<pair<int,int>>
#define vpll             vector<pair<ll,ll>>
#define vstr             vector<string>
#define pb               push_back
#define mp               make_pair
#define yes              cout << "YES" << endl
#define no               cout << "NO" << endl
#define out(x)           cout << (x) << endl
#define in(x)            cin >> (x)
const int INF = INT_MAX;
const int MAX = 200005;

void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

void printvi(vi arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

void printvll(vl arr) {
    lp(i, sz(arr))cout << arr[i] << " ";
    cout << endl;
}

bool sortbysec(const pair<int, int> &a,
               const pair<int, int> &b) {
    return (a.second < b.second);
}

void solve() {
    int n;
    in(n);
    vi arr(n);
    vi freq(n + 1, 0);
    lp(i, n) {
        int x;
        in(x);
        freq[x]++;
        arr[i] = x;
    }
    if(n==1){
        if(arr[0]==n)
            printvi(arr);
        else{
            arr[0]=n;
            printvi(arr);
        }
    }
    else {
        vi flag;
        for (int i = 1; i <= n; i++) {
            if (freq[i] == 0) {
                flag.pb(i);
            }
        }
        //printvi(freq);
        //printvi(flag);
        int i = 0;
        while (!flag.empty()) {
            if(arr[i]>n){
                freq[flag[0]]++;
                arr[i] = flag[0];
                flag.erase(flag.begin());
            }
            else if (freq[arr[i]] > 1) {
                freq[arr[i]]--;
                freq[flag[0]]++;
                arr[i] = flag[0];
                flag.erase(flag.begin());
            }
            i++;
        }
        printvi(arr);
    }

}

int main() {
    //freopen("jumping.in", "r", stdin);
    run();
    solve();
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int hash[n + 1]{}, mp[n + 1]{};
	int ar[n];
	for(int i = 0; i < n; i++) cin >> ar[i], hash[ar[i]] = 1;
	int p = 1;
	for(int i = 1; i <= n; i++){
		if(hash[i] == 0){
			p = i;
			break;
		}
	}
	//cout << p << endl;
	for(int i = 0; i < n; i++){
		if(mp[ar[i]] == 0){
			cout << ar[i] << ' ';
			mp[ar[i]] = 1;
		}
		else{
			while(hash[p] != 0) p++;
			cout << p << ' ';
			hash[p] = 1;
			mp[p] = 1;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int hash[10001]{}, mp[10001]{};
	int ar[n];
	for(int i = 0; i < n; i++) cin >> ar[i], hash[ar[i]] = 1;
	int p = 1;
	for(int i = 1; i <= n; i++){
		if(hash[i] == 0){
			p = i;
			break;
		}
	}
	//cout << p << endl;
	for(int i = 0; i < n; i++){
		if(mp[ar[i]] == 0){
			cout << ar[i] << ' ';
			mp[ar[i]] = 1;
		}
		else{
			while(hash[p] != 0) p++;
			cout << p << ' ';
			hash[p] = 1;
			mp[p] = 1;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int hash[10001]{};
	int ar[n], mn = INT_MAX;
	for(int i = 0; i < n; i++) cin >> ar[i], mn = min(mn, ar[i]);
	int p = mn;
	for(int i = 0; i < n; i++){
		if(hash[ar[i]] == 0){
			cout << ar[i] << ' ';
			hash[ar[i]] = 1;
		}
		else{
			while(hash[p] != 0) p++;
			cout << p << ' ';
			hash[p] = 1;
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int present[n + 1]{}, ar[n];
	for(int i = 0; i < n; i++){
		cin >> ar[i];
		if(ar[i] <= n)
			present[ar[i]] = 1;
	}
	vector <int> not_present;
	for(int i = 1 ; i <= n; i++){
		if(present[i] == 0)
			not_present.push_back(i);
	}
	set <int> s;
	int p = 0;
	for(int i = 0; i < n; i++){
		if(s.count(ar[i]) || ar[i] > n)
			ar[i] = not_present[p++];
		else s.insert(ar[i]);
	}
	for(int i = 0; i < n; i++) cout << ar[i] << ' ';
	cout << endl;
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int hash[n + 1]{};
	int ar[n];
	for(int i = 0; i < n; i++) cin >> ar[i];
	int p = 1;
	for(int i = 0; i < n; i++){
		if(hash[ar[i]] == 0){
			cout << ar[i] << ' ';
			hash[ar[i]] = 1;
		}
		else{
			while(hash[p] != 0) p++;
			cout << p << ' ';
			hash[p] = 1;
		}
	}
	return 0;
}


	#include <bits/stdc++.h>
	#include <set>
	#define ll long long
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
	#define rep(i,n) for(i=0;i<n;i++)
	#define repk(i,k,n) for(i=k;i<n;i++)
	using namespace std;
	void fastio()
	{
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	ll int multiply(ll int a,ll int b)
	{
		ll int ans=(a%mod*b%mod)%mod;
		return ans;
	}
	ll int add(ll int a, ll int b)
	{
		ll int ans=(a%mod+b%mod)% mod;
		return ans;
	}

	void solve()
	{
		ll int n;
		cin>>n;
		ll int a[n],i;
		rep(i,n)
		cin>>a[i];
		ll int f[n+1]={0};

		rep(i,n)
		{

			if(a[i]>n)
				{a[i]=0;

					continue;}
			f[a[i]]++;
			if (f[a[i]]>1)
			{
				a[i]=0;
				f[a[i]]--;

			}
		}
		// rep(i,n)
		// cout<<a[i]<<" ";
		// cout<<endl;
		vector<ll int> rem;
		repk(i,1,n+1)
		{
			if (f[i]==0)
				rem.pb(i);
		}
		ll int p=0;
		rep(i,n)
		{
			if (a[i]==0)
			{
				a[i]=rem[p++];
			}
		}
		rep(i,n)
		cout<<a[i]<<" ";
		cout<<endl;
	}

	int main()
	{
		fastio();
	    ll int t;
	    // cin>>t;
	    t=1;
	    while(t--)
	    {
	    	solve();
	    }
	}


	#include <bits/stdc++.h>
	#include <set>
	#define ll long long
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
	#define rep(i,n) for(i=0;i<n;i++)
	#define repk(i,k,n) for(i=k;i<n;i++)
	using namespace std;
	void fastio()
	{
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	ll int multiply(ll int a,ll int b)
	{
		ll int ans=(a%mod*b%mod)%mod;
		return ans;
	}
	ll int add(ll int a, ll int b)
	{
		ll int ans=(a%mod+b%mod)% mod;
		return ans;
	}

	void solve()
	{
		ll int n;
		cin>>n;
		ll int a[n],i;
		rep(i,n)
		cin>>a[i];
		ll int f[n+1]={0};

		rep(i,n)
		{
			f[a[i]]++;
			if (f[a[i]]>1)
			{
				a[i]=0;
				f[a[i]]--;

			}
		}
		vector<ll int> rem;
		repk(i,1,n+1)
		{
			if (f[i]==0)
				rem.pb(i);
		}
		ll int p=0;
		rep(i,n)
		{
			if (a[i]==0)
			{
				a[i]=rem[p++];
			}
		}
		rep(i,n)
		cout<<a[i]<<" ";
		cout<<endl;
	}

	int main()
	{
		fastio();
	    ll int t;
	    // cin>>t;
	    t=1;
	    while(t--)
	    {
	    	solve();
	    }
	}


	#include <bits/stdc++.h>
	#include <set>
	#define ll long long
	#include <string>
	#define pb push_back
	#define mp make_pair
	# define pi 3.14159265358979323846
	#define mod 1000000007
	#define rep(i,n) for(i=0;i<n;i++)
	#define repk(i,k,n) for(i=k;i<n;i++)
	using namespace std;
	void fastio()
	{
		#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	    #endif
	    ios_base::sync_with_stdio(false);
	    cin.tie(NULL);
	    cout.tie(NULL);

	}
	ll int multiply(ll int a,ll int b)
	{
		ll int ans=(a%mod*b%mod)%mod;
		return ans;
	}
	ll int add(ll int a, ll int b)
	{
		ll int ans=(a%mod+b%mod)% mod;
		return ans;
	}

	void solve()
	{
		ll int n;
		cin>>n;
		ll int a[n],i;
		rep(i,n)
		cin>>a[i];
		ll int f[n+1]={0};

		rep(i,n)
		{

			if(a[i]>n)
				{a[i]=0;

					continue;}
			f[a[i]]++;
			if (f[a[i]]>1)
			{
				a[i]=0;
				f[a[i]]--;

			}
		}
		rep(i,n)
		cout<<a[i]<<" ";
		cout<<endl;
		vector<ll int> rem;
		repk(i,1,n+1)
		{
			if (f[i]==0)
				rem.pb(i);
		}
		ll int p=0;
		rep(i,n)
		{
			if (a[i]==0)
			{
				a[i]=rem[p++];
			}
		}
		rep(i,n)
		cout<<a[i]<<" ";
		cout<<endl;
	}

	int main()
	{
		fastio();
	    ll int t;
	    // cin>>t;
	    t=1;
	    while(t--)
	    {
	    	solve();
	    }
	}


#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;

//int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//cin>>t;
	//while(t--){}
	int n; cin>>n;
	vector<int> v(n), ans(n);
	for(int &x:v)cin>>x;
	set<int> aux;
	for(int i=0;i<n;i++){
		if(!aux.count(v[i]) && v[i]<=n && v[i]>=1){
			ans[i] = v[i];
			aux.insert(v[i]);
		}
	}

	int j = 1;
	for(int i=0;i<n;i++){
		if(ans[i] == 0){

			while(aux.count(j))
				j++;
			aux.insert(j);
			ans[i] = j;
		}
	}
	for(auto &x:ans)cout<<x<<" ";
	cout<<"\n";
	return 0;
}


#include<bits/stdc++.h>
#define lint long long
#define st first
#define nd second
#define INF 0x3f3f3f3f

using namespace std;

//int t;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//cin>>t;
	//while(t--){}
	int n; cin>>n;
	vector<int> v(n), ans(n);
	for(int &x:v)cin>>x;
	set<int> aux;
	for(int i=0;i<n;i++){
		if(!aux.count(v[i])){
			ans[i] = v[i];
			aux.insert(v[i]);
		}
	}

	int j = 1;
	for(int i=0;i<n;i++){
		if(ans[i] == 0){

			while(aux.count(j))
				j++;
			aux.insert(j);
			ans[i] = j;
		}
	}
	for(auto &x:ans)cout<<x<<" ";
	cout<<"\n";
	return 0;
}


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

#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(iter) (iter).begin(), (iter).end()
#define mp make_pair
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define arin(vect) for (int i = 0; i < (vect).size(); i++) cin >> (vect)[i];
const char el = '\n';
const long double PI = acos((long double)-1);
const double Pi = acos((double)-1);
constexpr int pct(int x) { return __builtin_popcount(x); }

struct show {
#ifdef NATURE_VALLEY
    template<typename V, typename T>
    static void d(V name,T begin,T end){cerr<<"DEBUG: "<<name<<" = [";while(begin!=end)
        {cerr<<(*begin);++begin;if(begin!=end)cerr<<", ";}cerr<<"]\n";}
    template<typename V, typename T>
    static void dm(V name,T begin,T end){cerr<<"DEBUG: "<<name<<" = {\n";while(begin!=end)
        {cerr<<"  ["<<begin->first<<": "<<begin->second<<"],\n";++begin;}cerr<<"}\n";}
    template<typename V, typename T>
    static void debug(V name, T value){cerr<<"DEBUG: ("<<name<<" = "<<value<<")\n";}
#else
    template<typename V,typename T>
    static void d(V name,T begin,T end){}
    template<typename V,typename T>
    static void dm(V name,T begin,T end){}
    template<typename V, typename T>
    static void debug(V name, T value){}
#endif
}; // struct show
#define showd(var) show::d(#var, all(var))
#define showdm(var) show::dm(#var, all(var))
#define debug(var) show::debug(#var, var)

void solve() {
    int n;
    cin >> n;
    vector<int> ar(n);
    arin(ar);
    unordered_set<int> s;
    s.reserve(n);
    for (int i = 0; i < n; i++) {
        if (ar[i] <= n) s.insert(ar[i]);
    }
    vector<int> other;
    other.reserve(n);
    for (int i = 1; i <= n; i++) {
        if (s.find(i) == s.end()) other.pb(i);
    }
    for (int i = 0; i < n; i++) {
        if (s.find(ar[i]) == s.end()) {
            ar[i] = other.back();
            other.pop_back();
        } else {
            s.erase(ar[i]);
        }
    }
    for (int i = 0; i < n; i++) {
        cout << ar[i] << " ";
    }
    cout << el;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // READ THE PROBLEM STATEMENT
    // int t; cin >> t; while (t--)
        solve();

    return 0;
}