#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second % 4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {

                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        int single = 0;
        vector<int> ss,ds;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                        ss.push_back(it.first);
                }
                else if(it.second%2 == 0)
                {
                    ds.push_back(it.first);
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                for(int j=0;j<it.second/4;j++)
                    ss.push_back(it.first);
            }
        }
        if(cnt > 1)
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<n/2;i++)
            {
                for(int j=0;j<n/2;j++)
                {
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
            int j = k;
            for(;j<ss.size();j++)
            {
                ds.push_back(ss[k]);
                ds.push_back(ss[k]);
            }
            k = 0;
            for(int i=0;i<n/2;i++)
            {
                ans[i][n/2] = ds[k];
                ans[n-1-i][n/2] = ds[k];
                k++;
                ans[n/2][i] = ds[k];
                ans[n/2][n-1-i] = ds[k];
                k++;
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second % 4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {

                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        vector<int> ss,ds;
        int single = -1;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%2 == 0)
                {
                    ds.push_back(it.first);
                }
                else if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                        ss.push_back(it.first);
                }
                else if(it.second%4 == 3)
                {
                    cnt++;
                    single = it.first;
                    for(int j=0;j<it.second/4;j++)
                    {
                        ss.push_back(it.first);
                    }
                    for(int j=0;j<it.second/2 -it.second/4;j++)
                    {
                        ds.push_back(it.first);
                    }
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                for(int j=0;j<it.second/4;j++)
                    ss.push_back(it.first);
            }
        }
        if(cnt > 1 || ss.size() < (n/2)*(n/2))
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<n/2;i++)
            {
                for(int j=0;j<n/2;j++)
                {
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
            int j = k;
            for(;j<ss.size();j++)
            {
                ds.push_back(ss[j]);
                ds.push_back(ss[j]);
            }
            k = 0;
            for(int i=0;i<n/2;i++)
            {
                ans[i][n/2] = ds[k];
                ans[n-1-i][n/2] = ds[k];
                k++;
                ans[n/2][i] = ds[k];
                ans[n/2][n-1-i] = ds[k];
                k++;
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n*n);
    vector<int> s;
    map<int,int> m;
    int res = 0;
    int ans[n][n];
    for(int i=0;i<n*n;i++)
    {
        cin >> a[i];
        m[a[i]]++;
        if(m[a[i]]%4 == 1)
        {
            s.push_back(a[i]);
        }
    }
    if(n%2 == 0)
    {
        for(auto it: m)
        {
            if(it.second%4 != 0)
            {
                res = -1;
                break;
            }
        }
        int k = 0;
        for(int i=0;i<n/2;i++)
        {
            for(int j=0;j<n/2;j++)
            {

                ans[i][j] = s[k];
                ans[i][n-1-j] = s[k];
                ans[n-1-i][j] = s[k];
                ans[n-1-i][n-1-j] = s[k];
                k++;
            }
        }
    }
    else
    {
        int cnt=0;
        int single = 0;
        vector<int> ss;
        for(auto it:m)
        {
            if(it.second%4 != 0)
            {
                if(it.second%4 == 1)
                {
                    cnt++;
                    single = it.first;
                }
                else
                {
                    res = -1;
                }
            }
            else
            {
                for(int j=0;j<it.second/4;j++)
                    ss.push_back(it.first);
            }
        }
        if(cnt > 1)
        {
            res = -1;
        }
        else
        {
            int k = 0;
            ans[n/2][n/2] = single;
            for(int i=0;i<n/2;i++)
            {
                for(int j=0;j<n/2;j++)
                {
                    if(k >= ss.size())
                    {
                        ss.push_back(single);
                    }
                    ans[i][j] = ss[k];
                    ans[i][n-1-j] = ss[k];
                    ans[n-1-i][j] = ss[k];
                    ans[n-1-i][n-1-j] = ss[k];
                    k++;
                }
            }
            for(int i = 0;i<n/2;i++)
            {
                if(k >= ss.size())
                {
                    ss.push_back(single);
                }
                ans[i][n/2] = ss[k];
                ans[n-1-i][n/2] = ss[k];
                ans[n/2][i] = ss[k];
                ans[n/2][n-1-i] = ss[k];
                k++;
            }
        }
    }
    if(res == -1)
    {
        cout << "NO" << endl;
        return 0;
    }
    else
    {
        cout << "YES" << endl;
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<n;j++)
            {
                cout << ans[i][j] <<  " ";
            }
            cout << endl;
        }
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define ll long long int

using namespace std;

int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i,j=1;
    cin>>n;
    int a[100010],arr[100010],unused[100010],in=0;
    memset(arr,0,sizeof(arr));
    memset(unused,0,sizeof(unused));
    for(i=1;i<=n;i++) unused[i] = i;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>=1 && a[i]<=n && arr[a[i]]==0)
        {
            unused[a[i]] = -1;
        }
        else
        {
            a[i] = -1;
        }
        //cout<<"un: "<<unused[i]<<endl;
        if(a[i]!=-1) arr[a[i]]++;
        if(arr[a[i]]>1 && a[i]!=-1)
        {
            a[i] = -1;
            arr[a[i]]--;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==-1)
        {
            while(1)
            {
                if(unused[j]!=-1)
                    break;
                j++;
                if(j>100000) break;
            }
            cout<<j<<" ";
            j++;
        }
        else
            cout<<a[i]<<" ";
    }
    cout<<endl;

    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define ll long long int

using namespace std;

int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i,j=1;
    cin>>n;
    int a[100010],arr[100010],unused[100010],in=0;
    memset(arr,0,sizeof(arr));
    memset(unused,0,sizeof(unused));
    for(i=1;i<=n;i++) unused[i] = i;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>=1 && a[i]<=n && arr[a[i]]==0)
        {
            unused[a[i]] = -1;
        }
        //cout<<"un: "<<unused[i]<<endl;
        if(a[i]!=-1)
        arr[a[i]]++;
        if(arr[a[i]]>1 && a[i]!=-1)
        {
            a[i] = -1;
            arr[a[i]]--;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==-1)
        {
            while(1)
            {
                if(unused[j]!=-1)
                    break;
                j++;
                if(j>100000) break;
            }
            cout<<j<<" ";
            j++;
        }
        else
            cout<<a[i]<<" ";
    }
    cout<<endl;

    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define ll long long int

using namespace std;

int main()
{
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int n,i,j=1;
    cin>>n;
    int a[n+1],arr[n+1],unused[n+1],in=0;
    memset(arr,0,sizeof(arr));
    memset(unused,0,sizeof(unused));
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        if(a[i]>=1 && a[i]<=n)
            unused[a[i]] = -1;
        else
            unused[i] = i;
        arr[a[i]]++;
        if(arr[a[i]]>1)
        {
            a[i] = -1;
            arr[a[i]]--;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(a[i]==-1)
        {
            while(1)
            {
                if(unused[j]!=-1)
                    break;
                j++;
            }
            cout<<j<<" ";
            j++;
        }
        else
            cout<<a[i]<<" ";
    }
    cout<<endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5 + 10;
int arr[Maxn];

map <int, int> mp;
vector <int> vr;

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

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

		mp[arr[i]]++;
	}

	for (int i = 1; i <= n; i++)
		if (mp[i] == 0)
			vr.push_back(i);

	int sz = vr.size();

	for (int i = 0; i < sz; i++)
		for (int j = 0; j < n; j++)
			if (mp[arr[j]] > 1)
			{
				mp[arr[j]]--;
				arr[j] = vr[i];
				break;
			}

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

	cout << '\n';

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5 + 10;
int arr[Maxn];

map <int, int> mp;
vector <int> vr;

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

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

		mp[arr[i]]++;
	}

	for (int i = 1; i <= n; i++)
		if (mp[i] == 0)
			vr.push_back(i);

	int sz = vr.size();

	for (int i = 0; i < sz; i++)
		for (int j = 0; j < n; j++)
			if (mp[arr[j]] > 1)
			{
				arr[j] = vr[i];
				mp[arr[j]]--;
				break;
			}

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

	cout << '\n';

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5 + 10;
int arr[Maxn];
int mk[Maxn];

map <int, int> mp;
vector <int> vr;

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

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

		mp[arr[i]]++;
	}

	for (int i = 1; i <= n; i++)
		if (mp[i] == 0)
			vr.push_back(i);

	int sz = vr.size();

	int i = 0;

	for (int j = 0; j < n; j++)
		if (mp[arr[j]] > 1 || arr[j] > n)
			{
				mp[arr[j]]--;
				arr[j] = vr[i];
				mp[arr[j]]++;
				i++;
			}

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

	cout << '\n';

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5 + 10;
int arr[Maxn];
int mk[Maxn];

map <int, int> mp;
vector <int> vr;

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

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

		mp[arr[i]]++;
	}

	for (int i = 1; i <= n; i++)
		if (mp[i] == 0)
			vr.push_back(i);

	int sz = vr.size();

	int i = 0;

	for (int j = 0; j < n; j++)
		if (mp[arr[j]] > 1 || arr[j] > n)
			{
				mp[arr[j]]--;
				arr[j] = vr[i];
				i++;

				break;
			}

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

	cout << '\n';

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5 + 10;
int arr[Maxn];

map <int, int> mp;
vector <int> vr;

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

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

		mp[arr[i]]++;
	}

	for (int i = 1; i <= n; i++)
		if (mp[i] == 0)
			vr.push_back(i);

	int sz = vr.size();

	for (int i = 0; i < sz; i++)
		for (int j = 0; j < n; j++)
			if (mp[arr[j]] > 1 || arr[j] > n)
			{
				mp[arr[j]]--;
				arr[j] = vr[i];
				break;
			}

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

	cout << '\n';

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int Maxn = 1e5 + 10;
int arr[Maxn];
int mk[Maxn];

map <int, int> mp;
vector <int> vr;

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

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

		mp[arr[i]]++;
	}

	for (int i = 1; i <= n; i++)
		if (mp[i] == 0)
			vr.push_back(i);

	int sz = vr.size();

	int i = 0;

	for (int j = 0; j < n; j++)
		if (mp[arr[j]] > 1 || arr[j] > n)
			{
				mp[arr[j]]--;
				arr[j] = vr[i];
				mp[arr[j]]++;
				i++;

				break;
			}

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

	cout << '\n';

	return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int binSearch(int* arr, int b, int e, int v){
    if(b>=e && b!=v) return 0;
    int mid=(b+e)/2;
    if(arr[mid]==v) return 1;
    else if(arr[mid]>v) binSearch(arr, b, mid-1, v);
    else binSearch(arr, mid+1,e, v);
}

int main(){
int n,x,f;
cin>>n;

int mass[100001];
int vec[100001];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}

bool tr;
int p=0;

for(int i=0;i<n;i++){
    if(find(&mass[0], &mass[n], i+1)==&mass[n]){
     vec[p]=i+1;
        p++;
 }
}

//for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
//cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    for(int h=0;h<i;h++){
    if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       break;
    }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
map<int,bool>ahmed;map<int,bool>take;
int n,j=1;cin>>n;int arr[n];
for(int k=0;k<n;k++)cin>>arr[k],ahmed[arr[k]]=true;
for(int k=0;k<n;k++){
if(!take[arr[k]]&&arr[k]<=n)cout<<arr[k]<<" ",take[arr[k]]=true;
else{while(ahmed[j])j++;cout<<j<<" "; j++;}}}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int bsearch(int *arr, int size, int value)
{
    int l = 0;
    int r = size;

    while (l <= r)
    {
        int mid = (r + l)/2;
        if (arr[mid] == value) return 1;
        if (arr[mid] < value) l = ++mid;
        if (arr[mid] > value) r = --mid;
    }
    return 0;
};

int main(){
int n,x,f;
cin>>n;
f=1;
int* mass=new int[n];
int* mass2=new int[n];
for(int i=0;i<n;i++){
  cin>>mass[i];
}

if(n==1) mass2[0]=1;
else{
for(int i=0;i<n;i++){
  if(bsearch(mass2, i+1, mass[i])==1){
       // cout<<mass[i]<<endl;
        while(true){
            if(bsearch(mass2, i+1, f)==1){
                    ++f;
            }
            else{
                    mass2[i]=f;
                    ++f;
                    break;
            }
        }
  }
  else mass2[i]=mass[i];
 // for_each(&mass2[0], &mass2[n], [](int x){cout<<x<<" ";});
  //cout<<endl;
}
}

for_each(&mass2[0], &mass2[n], [](int x){cout<<x<<" ";});

}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int binSearch(int* arr, int b, int e, int v){
    if(b>=e && b!=v) return 0;
    int mid=(b+e)/2;
    if(arr[mid]==v) return 1;
    else if(arr[mid]>v) binSearch(arr, b, mid-1, v);
    else binSearch(arr, mid+1,e, v);
}

int main(){
int n,x,f;
cin>>n;

int* mass=new int[n];
int* vec=new int[n];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}

bool tr;
int p=0;

for(int i=0;i<n;i++){
    if(find(&mass[0], &mass[n], i+1)==&mass[n]){
     vec[p]=i+1;
        p++;
 }
}

//for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
//cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    for(int h=0;h<i;h++){
    if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       break;
    }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int bsearch(int *arr, int size, int value)
{
    int l = 0;
    int r = size;

    while (l <= r)
    {
        int mid = (r + l)/2;
        if (arr[mid] == value) return 1;
        if (arr[mid] < value) l = ++mid;
        if (arr[mid] > value) r = --mid;
    }
    return 0;
};

int main(){
int n,x,f;
cin>>n;
f=1;

int* mass=new int[n];
int* vec=new int[n];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}
bool tr=true;
int p=0;
for(int i=0;i<n;i++){
        tr=true;
    for(int j=0;j<n;j++){
            if(mass[j]==i+1 && j!=i){
                tr=false;
                break;
            }
    }
    if(tr){
     vec[p]=i+1;
        p++;
 }
}

//for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
//cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    for(int h=0;h<i;h++){
    if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       break;
    }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int main(){
int n,x,f;
cin>>n;

int* mass=new int[n];
int* vec=new int[n];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}
bool tr=true;
int p=0;
for(int i=0;i<n;i++){
        tr=true;
    for(int j=0;j<n;j++){
            if(mass[j]==i+1 && j!=i){
                tr=false;
                break;
            }
    }
    if(tr){
     vec[p]=i+1;
        p++;
 }
}

//for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
//cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    for(int h=0;h<i;h++){
    if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       break;
    }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int bsearch(int *arr, int size, int value)
{
    int l = 0;
    int r = size;

    while (l <= r)
    {
        int mid = (r + l)/2;
        if (arr[mid] == value) return 1;
        if (arr[mid] < value) l = ++mid;
        if (arr[mid] > value) r = --mid;
    }
    return 0;
};

int main(){
int n,x,f;
cin>>n;
f=1;
n++;
int* mass=new int[n];
int* mass2=new int[n];
for(int i=0;i<n-1;i++){
  cin>>mass[i];
}
mass[n-1]=-1;
if(n==2) mass2[0]=1;
else{
for(int i=0;i<n-1;i++){
  if(bsearch(mass2, i+1, mass[i])==1){
        while(true){
            if(bsearch(mass2, i+1, f)==1){
                    ++f;
            }
            else if(bsearch(mass, n, f)==0){
                   // cout<<f<<endl;
                    mass2[i]=f;
                    ++f;
                    break;
                    }

                    else
                        ++f;
        }
  }

  else mass2[i]=mass[i];
}
}

for_each(&mass2[0], &mass2[n-1], [](int x){cout<<x<<" ";});

}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int main(){
int n,x,f;
cin>>n;

int* mass=new int[n];
int* vec=new int[n];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}

bool tr;
int p=0;
for(int i=0;i<n;i++){
        tr=true;
    for(int j=0;j<n;j++){
            if(mass[j]==i+1){
                tr=false;
                break;
            }
    }
    if(tr){
     vec[p]=i+1;
        p++;
 }
}

//for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
//cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    for(int h=0;h<i;h++){
    if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       break;
    }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int binSearch(int* arr, int b, int e, int v){
    if(b>=e && b!=v) return 0;
    int mid=(b+e)/2;
    if(arr[mid]==v) return 1;
    else if(arr[mid]>v) binSearch(arr, b, mid-1, v);
    else binSearch(arr, mid+1,e, v);
}

int main(){
int n,x,f;
cin>>n;

int mass[100001];
int vec[100001];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}

bool tr;
int p=0;

for(int i=0;i<n;i++){
    if(find(&mass[0], &mass[n], i+1)==&mass[n]){
     vec[p]=i+1;
        p++;
 }
}

//for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
//cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    //for(int h=0;h<i;h++){
        if(find(&mass[0], &mass[i], mass[i])!=&mass[i]){
   // if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       //break;
   // }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int main(){
int n,x,f;
cin>>n;

int* mass=new int[n];
int* vec=new int[n];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}

bool tr;
int p=0;
for(int i=0;i<n;i++){
        tr=true;
    for(int j=0;j<n;j++){
            if(mass[j]==i+1){
                tr=false;
                break;
            }
    }
    if(tr){
     vec[p]=i+1;
        p++;
 }
}

for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    for(int h=0;h<i;h++){
    if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       break;
    }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int bsearch(int *arr, int size, int value)
{
    int l = 0;
    int r = size;

    while (l <= r)
    {
        int mid = (r + l)/2;
        if (arr[mid] == value) return 1;
        if (arr[mid] < value) l = ++mid;
        if (arr[mid] > value) r = --mid;
    }
    return 0;
};

int main(){
int n,x,f;
cin>>n;
f=1;
n++;
int* mass=new int[n];
int* mass2=new int[n];
for(int i=0;i<n-1;i++){
  cin>>x;
if(x>n-1)x=1;
mass[i]=x;
}
mass[n-1]=-1;
if(n==2) mass2[0]=1;
else{
for(int i=0;i<n-1;i++){
  if(bsearch(mass2, i+1, mass[i])==1){
        while(true){
            if(bsearch(mass2, i+1, f)==1){
                    ++f;
            }
            else if(bsearch(mass, n, f)==0){
                   // cout<<f<<endl;
                    mass2[i]=f;
                    ++f;
                    break;
                    }

                    else
                        ++f;
        }
  }

  else mass2[i]=mass[i];
}
}

for_each(&mass2[0], &mass2[n-1], [](int x){cout<<x<<" ";});

}


#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <vector>

using namespace std;

void sr(int b,int e, int mass[]){
    int b1=b;
    int e1=e;
    int m=mass[e];
    while(b1<=e1){
        while(mass[b1]<m) b1++;
        while(mass[e1]>m) e1--;
        if(b1<=e1){
            int temp=mass[b1];
            mass[b1]=mass[e1];
            mass[e1]=temp;
            b1++;
            e1--;
        }

    }
    if(b1<e)
        sr(b1, e, mass);
    if(b<e1)
        sr(b, e1, mass);

}

int main(){
int n,x,f;
cin>>n;

int* mass=new int[n];
int* vec=new int[n];
for(int i=0;i<n;i++){
  cin>>x;
if(x>n)x=1;
mass[i]=x;
}

bool tr;
int p=0;
for(int i=0;i<n;i++){
        tr=true;
    for(int j=0;j<n;j++){
            if(i==j) continue;
            if(mass[j]==i+1){
                tr=false;
                break;
            }
    }
    if(tr){
     vec[p]=i+1;
        p++;
 }
}

//for_each(&vec[0], &vec[p], [](int x){cout<<x<<" ";});
//cout<<endl;

int k=0;
for(int i=0;i<n;i++){
    for(int h=0;h<i;h++){
    if(mass[h]==mass[i]){
       mass[i]=vec[k];
       k++;
       break;
    }
}
}

for_each(&mass[0], &mass[n], [](int x){cout<<x<<" ";});
return 0;
}


/*
 * =====================================================================================
 *
 *       Filename:  315_div2_B_inventory.cpp
 *
 *    Description:  http://codeforces.com/contest/569/problem/B
 *
 *        Version:  1.0
 *        Created:  08/31/2015 05:54:15 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  Marius-Constantin Melemciuc
 *          email:
 *   Organization:
 *
 * =====================================================================================
 */

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

void solve(vector<int>& array) {
    int n = array.size();
    unordered_map<int, int> m;

    for (int i = 0; i < array.size(); i++) {
        m[array[i]]++;
    }

    if (array.size() == 1) {
        array[0] = 1;
    }

    bool found = false;
    for (int i = 0; i < n; i++) {
        if ((m[array[i]] > 1 || array[i] > n)) {
            found = false;
            for (int j = 1; j <= n && !found; j++) {
                if (m.find(j) == m.end()) {
                    m[array[i]]--;
                    array[i] = j;
                    m[j] = 1;
                    found = true;
                }
            }
        }
    }
}

int main() {
    int n;
    vector<int> array;
#ifndef ONLINE_JUDGE
    freopen("inventory.in", "r", stdin);
#endif /* ONLINE_JUDGE */

    cin >> n;

    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        array.push_back(value);
    }

    solve(array);

    for (auto it = array.begin(); it != array.end(); it++) {
        cout << *it << " ";
    }

    return 0;
}


/*
 * =====================================================================================
 *
 *       Filename:  315_div2_B_inventory.cpp
 *
 *    Description:  http://codeforces.com/contest/569/problem/B
 *
 *        Version:  1.0
 *        Created:  08/31/2015 05:54:15 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  Marius-Constantin Melemciuc
 *          email:
 *   Organization:
 *
 * =====================================================================================
 */

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

void solve(vector<int>& array) {
    int n = array.size();
    vector<int> nrs(array.size() + 1, 0);
    unordered_map<int, int> m;
    vector<bool> unchanged(array.size(), false);
    int x = 1;

    for (int i = 0; i < array.size(); i++) {
        if (m[array[i]] == 0 && array[i] <= n) {
            unchanged[i] = true;
        }
        m[array[i]]++;
    }

    for (int i = 0; i < array.size(); i++) {
        if (!unchanged[i]) {
            for (int j = 1; j <= n; j++) {
                if (m.find(j) == m.end()) {
                    array[i] = j;
                    m[j] = 1;
                    break;
                }
            }
        }
    }
}

int main() {
    int n;
    vector<int> array;
#ifndef ONLINE_JUDGE
    freopen("inventory.in", "r", stdin);
#endif /* ONLINE_JUDGE */

    cin >> n;

    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        array.push_back(value);
    }

    solve(array);

    for (auto it = array.begin(); it != array.end(); it++) {
        cout << *it << " ";
    }

    return 0;
}


/*
 * =====================================================================================
 *
 *       Filename:  315_div2_B_inventory.cpp
 *
 *    Description:  http://codeforces.com/contest/569/problem/B
 *
 *        Version:  1.0
 *        Created:  08/31/2015 05:54:15 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  Marius-Constantin Melemciuc
 *          email:
 *   Organization:
 *
 * =====================================================================================
 */

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

// O(n) time
void solve(vector<int>& array) {
    int n = array.size();
    unordered_map<int, int> m;
    vector<bool> unchanged(array.size(), false);
    int first_index = 1;

    for (int i = 0; i < array.size(); i++) {
        if (m.find(array[i]) == m.end() && array[i] > 0 && array[i] <= n) {
            unchanged[i] = true;
        }
        m[array[i]]++;
    }

    first_index = 1;
    for (int i = 0; i < array.size(); i++) {
        if (!unchanged[i]) {
            for (int j = first_index; j <= n; j++) {
                if (m.find(j) == m.end()) {
                    array[i] = j;
                    m[j] = 1;
                    first_index = j + 1;
                    break;
                }
            }
        }
    }
}

int main() {
    int n;
    vector<int> array;
#ifndef ONLINE_JUDGE
    freopen("inventory.in", "r", stdin);
#endif /* ONLINE_JUDGE */

    cin >> n;

    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        array.push_back(value);
    }

    solve(array);

    for (auto it = array.begin(); it != array.end(); it++) {
        cout << *it << " ";
    }

    return 0;
}


/*
 * =====================================================================================
 *
 *       Filename:  315_div2_B_inventory.cpp
 *
 *    Description:  http://codeforces.com/contest/569/problem/B
 *
 *        Version:  1.0
 *        Created:  08/31/2015 05:54:15 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  Marius-Constantin Melemciuc
 *          email:
 *   Organization:
 *
 * =====================================================================================
 */

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

void solve(vector<int>& array) {
    int n = array.size();
    unordered_map<int, int> m;
    unordered_map<int, int> m2;

    for (int i = 0; i < array.size(); i++) {
        m[array[i]]++;
        m2[array[i]] = i + 1;
    }

    if (array.size() == 1) {
        array[0] = 1;
    }

    bool found = false;
    for (int i = 0; i < n; i++) {
        if (m.find(array[i]) != m.end() && (m[array[i]] > 1 || array[i] > n)) {
            found = false;
            for (int j = 1; j <= n && !found; j++) {
                if (m.find(j) == m.end()) {
                    m[array[i]]--;
                    array[i] = j;
                    m[j] = 1;
                    found = true;
                }
            }
        }
    }
}

int main() {
    int n;
    vector<int> array;
#ifndef ONLINE_JUDGE
    freopen("inventory.in", "r", stdin);
#endif /* ONLINE_JUDGE */

    cin >> n;

    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        array.push_back(value);
    }

    solve(array);

    for (auto it = array.begin(); it != array.end(); it++) {
        cout << *it << " ";
    }

    return 0;
}


/*
 * =====================================================================================
 *
 *       Filename:  315_div2_B_inventory.cpp
 *
 *    Description:  http://codeforces.com/contest/569/problem/B
 *
 *        Version:  1.0
 *        Created:  08/31/2015 05:54:15 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  Marius-Constantin Melemciuc
 *          email:
 *   Organization:
 *
 * =====================================================================================
 */

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

void solve(vector<int>& array) {
    int n = array.size();
    vector<int> nrs(array.size() + 1, 0);
    unordered_map<int, int> m;
    vector<bool> unchanged(array.size(), false);
    int x = 1;

    for (int i = 0; i < array.size(); i++) {
        if (m[array[i]] == 0 && array[i] <= n) {
            unchanged[i] = true;
        }
        m[array[i]]++;
    }

    x = 1;
    for (int i = 0; i < array.size(); i++) {
        if (!unchanged[i]) {
            for (int j = x; j <= n; j++) {
                if (m.find(j) == m.end()) {
                    array[i] = j;
                    m[j] = 1;
                    x = j + 1;
                    break;
                }
            }
        }
    }
}

int main() {
    int n;
    vector<int> array;
#ifndef ONLINE_JUDGE
    freopen("inventory.in", "r", stdin);
#endif /* ONLINE_JUDGE */

    cin >> n;

    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        array.push_back(value);
    }

    solve(array);

    for (auto it = array.begin(); it != array.end(); it++) {
        cout << *it << " ";
    }

    return 0;
}


/*
 * =====================================================================================
 *
 *       Filename:  315_div2_B_inventory.cpp
 *
 *    Description:  http://codeforces.com/contest/569/problem/B
 *
 *        Version:  1.0
 *        Created:  08/31/2015 05:54:15 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  Marius-Constantin Melemciuc
 *          email:
 *   Organization:
 *
 * =====================================================================================
 */

#include <iostream>
#include <vector>
#include <map>

using namespace std;

void solve(vector<int>& array) {
    int n = array.size();
    map<int, int> m;
    map<int, int> m2;

    for (int i = 0; i < array.size(); i++) {
        m[array[i]]++;
        m2[array[i]] = i + 1;
    }

    if (array.size() == 1) {
        array[0] = 1;
    }

    bool found = false;
    for (int i = 0; i < n; i++) {
        if (m.find(array[i]) != m.end() && (m[array[i]] > 1 || array[i] > n)) {
            found = false;
            for (int j = 1; j <= n && !found; j++) {
                if (m.find(j) == m.end()) {
                    m[array[i]]--;
                    array[i] = j;
                    m[j] = 1;
                    found = true;
                }
            }
        }
    }
}

int main() {
    int n;
    vector<int> array;
#ifndef ONLINE_JUDGE
    freopen("inventory.in", "r", stdin);
#endif /* ONLINE_JUDGE */

    cin >> n;

    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        array.push_back(value);
    }

    solve(array);

    for (auto it = array.begin(); it != array.end(); it++) {
        cout << *it << " ";
    }

    return 0;
}


/*
 * =====================================================================================
 *
 *       Filename:  315_div2_B_inventory.cpp
 *
 *    Description:  http://codeforces.com/contest/569/problem/B
 *
 *        Version:  1.0
 *        Created:  08/31/2015 05:54:15 PM
 *       Revision:  none
 *       Compiler:  gcc/g++
 *
 *         Author:  Marius-Constantin Melemciuc
 *          email:
 *   Organization:
 *
 * =====================================================================================
 */

#include <iostream>
#include <vector>
#include <map>

using namespace std;

void solve(vector<int>& array) {
    int n = array.size();
    map<int, int> m;

    for (int i = 0; i < array.size(); i++) {
        m[array[i]]++;
    }

    if (array.size() == 1) {
        array[0] = 1;
    }

    bool found = false;
    for (int i = 0; i < n; i++) {
        if (m.find(array[i]) != m.end() && m[array[i]] > 1) {
            found = false;
            for (int j = 1; j <= n && !found; j++) {
                if (m.find(j) == m.end()) {
                    m[array[i]]--;
                    array[i] = j;
                    m[j] = 1;
                    found = true;
                }
            }
        }
    }
}

int main() {
    int n;
    vector<int> array;
#ifndef ONLINE_JUDGE
    freopen("inventory.in", "r", stdin);
#endif /* ONLINE_JUDGE */

    cin >> n;

    int value;
    for (int i = 0; i < n; i++) {
        cin >> value;
        array.push_back(value);
    }

    solve(array);

    for (auto it = array.begin(); it != array.end(); it++) {
        cout << *it << " ";
    }

    return 0;
}


#include<iostream>
using namespace std;
int b[100001]={};
int main(){
    int n;
    while(cin>>n){
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
            b[a[i]]++;
        }
        for(int i=0;i<n;i++){
            while(b[a[i]]>1||a[i]>n){
                if(b[a[i]]>1){
                for(int j=i+1;j<n;j++){
                    if(a[j]==a[i]){
                        int x=1;
                        while(1){
                            if(b[x]==0){
                                a[j]=x;
                                b[x]++;
                                b[a[i]]--;
                                break;
                            }
                            else x++;
                        }
                    }
                }
                }
                else if(a[i]>n){
                        int x=1;
                        while(1){
                            if(b[x]==0){
                                a[i]=x;
                                b[x]++;
                                b[a[i]]--;
                                break;
                            }
                            else x++;
                        }
                }
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
bool b[100001]= {};
bool c[100001]= {};
int main()
{
    int n;
    while(cin>>n)
    {
        int a[n],x=0;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
            b[a[i]]=true;
        }
        for(int i=0; i<n; i++)
        {
            if(c[a[i]]||a[i]>n)
            {
                while(1)
                {
                    x++;
                    if(!b[x])
                    {
                        a[i]=x;
                        break;
                    }
                }
            }
            else c[a[i]]=true;
        }
        for(int i=0; i<n; i++)
        {
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
int b[100001]= {};
bool c[100001]= {};
int main()
{
    int n;
    while(cin>>n)
    {
        int a[n],x=0;
        for(int i=0; i<n; i++)
        {
            cin>>a[i];
            b[a[i]]++;
        }
        for(int i=0; i<n; i++)
        {
            if(c[a[i]]||a[i]>n)
            {
                while(1)
                {
                    x++;
                    if(b[x]==0)
                    {
                        a[i]=x;
                        break;
                    }
                }
            }
            else c[a[i]]=true;
        }
        for(int i=0; i<n; i++)
        {
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
int b[100001]={};
int main(){
    int n;
    while(cin>>n){
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
            b[a[i]]++;
            if(b[a[i]]>1){
                int x=1;
                while(1){
                    if(b[x]==0){
                        b[a[i]]--;
                        b[x]++;
                        a[i]=x;
                        break;
                    }
                    else x++;
                }
            }
        }
        for(int i=0;i<n;i++){
            if(a[i]>n){
                int x=1;
                while(1){
                    if(b[x]==0){
                        b[a[i]]--;
                        b[x]++;
                        a[i]=x;
                        break;
                    }
                    else x++;
                }
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
int b[100001]={};
int main(){
    int n;
    while(cin>>n){
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
            b[a[i]]++;
        }
        for(int i=0;i<n;i++){
            while(b[a[i]]>1||a[i]>n){
                for(int j=i;j<n;j++){
                    if(a[j]==a[i]||a[j]>n){
                        int x=1;
                        while(1){
                            if(b[x]==0){
                                a[j]=x;
                                b[x]++;
                                b[a[i]]--;
                                break;
                            }
                            else x++;
                        }
                    }
                }
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}


#include<iostream>
using namespace std;
int b[100001]={};
int main(){
    int n;
    while(cin>>n){
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
            b[a[i]]++;
        }
        for(int i=0;i<n;i++){
            while(b[a[i]]>1){
                for(int j=i+1;j<n;j++){
                    if(a[j]==a[i]){
                        int x=1;
                        while(1){
                            if(b[x]==0){
                                a[j]=x;
                                b[x]++;
                                b[a[i]]--;
                                break;
                            }
                            else x++;
                        }
                    }
                }
            }
        }
        for(int i=0;i<n;i++){
            cout<<a[i]<<" ";
        }
        cout<<endl;
    }
}


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

int main() {
    ios::sync_with_stdio(false);
    long long int t,temp,i,j;
    cin>>t;
    unordered_map<long long int,long long int> a;
    long long int b[t];

    for(i=0;i<t;i++){
        cin>>temp;
        b[i]=temp-1;
        a[temp-1]++;
    }
    long long int mj,okk[t];
    j=0;
    for(i=0;i<t;i++){
        if(a[i]==0){
            okk[j]=i;
            j++;
        }
    }
    j=0;
    for(i=0;i<t;i++){
        temp=b[i];
        if(a[temp]!=1){
            a[temp]--;
            cout<<okk[j]+1<<" ";
            j++;
        }
        else{
            cout<<temp+1<<" ";
        }
//      cout<<endl;
    }
    return 0;
}


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

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

    long long int t,temp,i,j;
    cin>>t;
    long long int a[t];
    long long int b[t];
    for(i=0;i<t;i++){
        a[i]=0;
    }
    for(i=0;i<t;i++){
        cin>>temp;
        b[i]=temp-1;
        a[temp-1]++;
    }
    j=0;
    for(i=0;i<t;i++){
        temp=b[i];
        if(a[temp]!=1){
            a[temp]--;
            for(;j<t&&a[j]!=0;j++){

            }
            a[j]++;
            cout<<j+1<<" ";
            j++;
        }
        else{
            cout<<temp+1<<" ";
        }
    }
    return 0;
}


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

int main() {
    long long int t,temp,i,j;
    cin>>t;
    map<long long int,long long int> a;
    long long int b[t];
    for(i=0;i<t;i++){
        cin>>temp;
        b[i]=temp-1;
        a[temp-1]++;
    }
    j=0;
    for(i=0;i<t;i++){
        temp=b[i];
        if(a[temp]!=1){
            a[temp]--;
            for(;j<t&&a[j]!=0;j++){

            }
            a[j]++;
            j++;
            cout<<j<<" ";
        }
        else{
            cout<<temp+1<<" ";
        }
    }
    return 0;
}


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

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

    long long int t,temp,i,j;
    cin>>t;
    long long int a[t];
    long long int b[t];
    for(i=0;i<t;i++){
        a[i]=0;
    }
    for(i=0;i<t;i++){
        cin>>temp;
        b[i]=temp-1;
        if(temp<=t){
            a[temp-1]++;
        }
    }
    j=0;
    for(i=0;i<t;i++){
        temp=b[i];
        if(temp>=t||a[temp]>1){
            if(temp<t){
                a[temp]--;
            }
            for(j=j;j<t;j++){
                if(a[j]==0){
                    break;
                }
            }
            a[j]=1;
            cout<<j+1<<" ";
            j++;
        }
        else{
            cout<<temp+1<<" ";
        }
    }
    return 0;
}


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

int main() {
    long long int t,temp,i,j;
    cin>>t;
    long long int a[t];
    long long int b[t];
    for(i=0;i<t;i++){
        a[i]=0;
    }
    for(i=0;i<t;i++){
        cin>>temp;
        b[i]=temp-1;
        a[temp-1]++;
    }
    j=0;
    for(i=0;i<t;i++){
        temp=b[i];
//      cout<<temp<<" "<<a[temp]<<" ";
        if(a[temp]!=1){
            a[temp]--;
            for(;j<t&&a[j]!=0;j++){

            }
            a[j]++;
            cout<<j+1<<" ";
        }
        else{
            cout<<temp+1<<" ";
        }
//      cout<<endl;
    }
    return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    long long int t,temp,i,j;
    cin>>t;
    long long int a[t];
    long long int b[t];
    for(i=0;i<t;i++){
        a[i]=0;
    }
    for(i=0;i<t;i++){
        cin>>temp;
        b[i]=temp-1;
        a[temp-1]++;
    }
    long long int okk[t];
    i=0;
    for(j=0;j<t;j++){
        if(a[j]==0){
            okk[i]=j;
            i++;
        }
    }
    j=0;
    for(i=0;i<t;i++){
        temp=b[i];
        if(a[temp]!=1){
            a[temp]--;
            cout<<okk[j]+1<<" ";
            j++;
        }
        else{
            cout<<temp+1<<" ";
        }
    }
    return 0;
}


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

long long int fastread(long long int* a)
{
 char c=0;
 while (c<33)
 c=getchar_unlocked();
 *a=0;
 while (c>33)
{
    *a=*a*10+c-'0';
    c=getchar_unlocked();
}
return 0;
}

int main() {
    long long int t,temp,i,j;
    fastread(&t);
    unordered_map<long long int,long long int> a;
    long long int b[t];

    for(i=0;i<t;i++){
        fastread(&temp);
        b[i]=temp-1;
        a[temp-1]++;
    }
    long long int mj,okk[t];
    j=0;
    for(i=0;i<t;i++){
        if(a[i]==0){
            okk[j]=i;
            j++;
        }
    }
    j=0;
    for(i=0;i<t;i++){
        temp=b[i];
        if(a[temp]!=1){
            a[temp]--;
            cout<<okk[j]+1<<" ";
            j++;
        }
        else{
            cout<<temp+1<<" ";
        }
//      cout<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

const int NN=2*100000;
int n,cnt;
int a[NN],flag[NN],ans[NN];
int p[NN];
int main () {
#ifndef ONLINE_JUDGE
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		 scanf("%d",&a[i]);
		 ans[i]=a[i];
		 flag[a[i]]=1;
	}
	if (n==1) {
		printf("1\n");
		return 0;
	}

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

	if (cnt==0) {
		for(int i=0; i<n; i++) printf("%d ",a[i]);
		puts(""); return 0;
	}
	int id=0;
	for(int i=1; i<=n; i++) if (flag[i]==0 && id!=cnt) flag[i]=1, ans[p[id]]=i,id++;
	for(int i=0; i<n; i++) printf("%d ",ans[i]);
	puts("");
	return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

const int NN=2*100000;
int n,cnt;
int a[NN],flag[NN],ans[NN];
int p[NN];
int main () {
#ifndef ONLINE_JUDGE
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		 scanf("%d",&a[i]);
		 ans[i]=a[i];
		 flag[a[i]]=1;
	}
	if (n==1) {
		printf("1\n");
		return 0;
	}

	for(int i=0; i<n-1; ) {
		if (a[i]==a[i+1]) p[cnt++]=i,i+=2;
		else i++;
	}
	if (cnt==0) {
		for(int i=0; i<n; i++) printf("%d ",ans[i]);
		puts(""); return 0;
	}
	int id=0;
	for(int i=1; i<=n; i++) if (flag[i]==0 && id<=cnt) flag[i]=1, ans[p[id++]]=i;
	for(int i=0; i<n; i++) printf("%d ",ans[i]);
	puts("");
	return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

const int NN=2*100000;
int n,cnt;
int a[NN],flag[NN],ans[NN];
int p[NN];
int main () {
#ifndef ONLINE_JUDGE
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		 scanf("%d",&a[i]);
		 ans[i]=a[i];
		 flag[a[i]]=1;
	}
	if (n==1) {
		printf("1\n");
		return 0;
	}

	for(int i=0; i<n-1; i++) {
		if (a[i]==a[i+1]) p[cnt++]=i;
	}
	if (cnt==0) {
		for(int i=0; i<n; i++) printf("%d ",a[i]);
		puts(""); return 0;
	}
	int id=0;
	for(int i=1; i<=n; i++) if (flag[i]==0 && id<=cnt) flag[i]=1, ans[p[id++]]=i;
	for(int i=0; i<n; i++) printf("%d ",ans[i]);
	puts("");
	return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

const int NN=2*100000;
int n,cnt;
int a[NN],flag[NN],ans[NN];
int p[NN];
int main () {
#ifndef ONLINE_JUDGE
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		 scanf("%d",&a[i]);
		 ans[i]=a[i];
		 flag[a[i]]=1;
	}
	if (n==1) {
		printf("1\n");
		return 0;
	}
	for(int i=0; i<n-1; ) {
		if (a[i]==a[i+1]) p[cnt++]=i,i+=2;
		else i++;
	}
	for(int i=0; i<cnt; i++)
		for(int j=1; j<=n; j++)
			if(!flag[j]) {
				flag[j]=1;
				ans[p[i]]=j; break;
			}
	for(int i=0; i<n; i++) printf("%d ",ans[i]);
	puts("");
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define NN 111111
int a[NN];
int id[NN];
int p[NN];
bool cmp(int i,int j){
	return a[i]<a[j];
}
bool cnt(int k,int l){
	return id[k]<id[l];
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("in.in", "r", stdin);
  freopen("out.out", "w", stdout);
#endif
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
  	cin>>a[i];
  	id[i]=i;
  	p[i]=i;
  }
  sort(id,id+n,cmp);
  sort(p,p+n,cnt);
  for(int i=0;i<n;i++)
  cout<<p[i]+1<<' ';
		return 0;
  }


#include <bits/stdc++.h>

using namespace std;

const int NN=2*100000;
int n,cnt;
int a[NN],flag[NN],b[NN];
int main () {
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	cin>>n;
	for(int i=0; i<n; i++) {
		scanf("%d",&a[i]);
		if (a[i]>n) a[i]=0;
		else flag[a[i]]++;
	}
	for(int i=1; i<=n; i++) if (!flag[i])  b[cnt++]=i;
	for(int j=0,i=0; i<n; i++) {
		if (a[i]==0) printf("%d ",b[j++]);
		else if (flag[a[i]]>1)  flag[a[i]]--, printf("%d ",b[j++]);
		else if(flag[a[i]]==1) printf("%d ",a[i]);
	}
	return 0;
}


#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

const int NN=2*100000;
int n,cnt;
int a[NN],flag[NN],ans[NN];
int p[NN];
int main () {
#ifndef ONLINE_JUDGE
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		 scanf("%d",&a[i]);
		 ans[i]=a[i];
		 flag[a[i]]=1;
	}
	if (n==1) {
		printf("1\n");
		return 0;
	}

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

	if (cnt==0) {
		for(int i=0; i<n; i++) printf("%d ",a[i]);
		puts(""); return 0;
	}
	int id=0;
	for(int i=1; i<=n; i++) if (flag[i]==0 ) flag[i]=1, ans[p[id]]=i,id++;
	for(int i=0; i<n; i++) printf("%d ",ans[i]);
	puts("");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define NN 100100
int a[NN],f[NN],d[NN];
set<int> re;
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {scanf("%d",&a[i]);f[i]=0;}
	for(int i=1;i<=n;i++) re.insert(i);
	for(int i=1;i<=n;i++){
		if(a[i]>n) a[i]=0;
		else f[a[i]]++;
	}
	for(int i=1;i<=n;i++) d[i]=f[i];
	for(int i=1;i<=n;i++){
		if(f[a[i]]>1) f[a[i]]--,a[i]=0;
	}
	for(int i=1;i<=n;i++) if(f[i]==1) re.erase(i);
	for(int i=1;i<=n;i++){
		if(a[i]==0) {
			a[i]=*re.begin();
			re.erase(*re.begin());
		}
	}
	for(int i=1;i<=n;i++) printf("%d ",a[i]);
}


#include<bits/stdc++.h>
using namespace std;
#define NN 100100
int a[NN],f[NN];
set<int> re;
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {scanf("%d",&a[i]);f[i]=0;}
	for(int i=1;i<=n;i++) re.insert(i);
	for(int i=1,j;i<n;i=j){
		if(a[i]==0) continue;
		else for(j=i+1;j<=n;j++){
			if(a[i]==a[j]) a[j]=0;
			else break;
		}
	}
	int t=0;
	for(int i=1;i<=n;i++){if(a[i]>n) t++,a[i]=0;}
	for(int i=1;i<=n;i++) {
		if(a[i]==0) f[i]=1,t++;
		else re.erase(a[i]);
	}
	for(int i=1;i<=n;i++){
		if(f[i]==1) {
			a[i]=*re.begin();
			re.erase(*re.begin());
		}
	}
	for(int i=1;i<=n;i++) printf("%d ",a[i]);
}


#include <iostream>

using namespace std;

int n;
int used[100010], arr[100010];

void replace(int pos)
{
	for(int j = 1; j <= n; j++)
	{
		if(used[j] == 0)
		{
			arr[pos] = j;
			used[j]++;
			break;
		}
	}
}

int main()
{

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		used[i+1] = 0;
	}

	for(int i = 0; i < n; i++)
		used[arr[i]]++;

	for(int i = 0; i < n; i++)
	{
		if(arr[i] > n)
		{
			replace(i);
		}
		else if(used[arr[i]] > 1)
		{
			used[arr[i]]--;
			replace(i);
		}
	}

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

	return 0;
}


#include <iostream>

using namespace std;

int n;
int used[100010];
/*int arr[100010];

void replace(int pos)
{
	for(int j = 1; j <= n; j++)
	{
		if(used[j] == 0)
		{
			arr[pos] = j;
			used[j]++;
			break;
		}
	}
}*/

int main()
{

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		//used[i+1] = 0;
	}
		/*
	for(int i = 0; i < n; i++)
		used[arr[i]]++;

	for(int i = 0; i < n; i++)
	{
		if(arr[i] > n)
		{
			replace(i);
		}
		else if(used[arr[i]] > 1)
		{
			used[arr[i]]--;
			replace(i);
		}
	}

	for(int i = 0; i < n; i++)
	{
		if(i == 0)
			cout << arr[i];
		else
			cout << " " << arr[i];
	}*/

	cout << 1;
	for(int i = 2; i <= n; i++)
		cout << " " << i;

	cout << endl;

	return 0;
}


#include <iostream>

using namespace std;

int n, last = 1;
int used[100010], arr[100010];

void replace(int pos)
{
	for(int j = last; j <= n; j++)
	{
		if(used[j] == 0)
		{
			arr[pos] = j;
			used[j]++;
			last = j;
			break;
		}
	}
}

int main()
{

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		used[i+1] = 0;
	}

	for(int i = 0; i < n; i++)
		used[arr[i]]++;

	for(int i = 0; i < n; i++)
	{
		if(arr[i] > n)
		{
			replace(i);
		}
		else if(used[arr[i]] > 1)
		{
			used[arr[i]]--;
			replace(i);
		}
	}

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

	return 0;
}


#include <iostream>
#include <list>
#include <algorithm>

using namespace std;

list<int> reps;
list<int>::iterator it;

int main()
{
	int n, last = 1;
	cin >> n;
	int arr[n];
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		it = find(reps.begin(), reps.end(), arr[i]);
		if(it != reps.end() || arr[i] > n) //exists
		{
			int aux = last;
			it = find(reps.begin(), reps.end(), aux);
			while(it != reps.end())
			{
				aux++;
				it = find(reps.begin(), reps.end(),aux);
			}
			arr[i] = aux;
			reps.insert(it, aux);
			last = aux+1;
		}
		else
			reps.insert(it, arr[i]);
	}

	cout << arr[0];
	for(int i = 1; i < n; i++)
		cout << " " << arr[i];

	cout << endl;

	return 0;
}


#include <iostream>
#include <list>
#include <algorithm>

using namespace std;

list<int> reps;
list<int> notas;
list<int>::iterator it;

int main()
{
	int n;
	cin >> n;
	int arr[n];

	it = notas.end();
	for(int i = 1; i <= n; i++)
		notas.insert(it, i);

	it = reps.end();
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		reps.insert(it, arr[i]);
		notas.remove(arr[i]);
	}

	for(int i = 0; i < n; i++)
	{
		int ctd = count(reps.begin(), reps.end(), arr[i]);
		if(ctd > 1 || arr[i] > n)
		{
			it = find(reps.begin(), reps.end(), arr[i]);
			reps.erase(it);
			it = notas.begin();
			arr[i] = *it;
			notas.remove(*it);
		}

	}

	cout << arr[0];
	for(int i = 1; i < n; i++)
		cout << " " << arr[i];

	cout << endl;

	return 0;
}


#include <iostream>
#include <list>
#include <algorithm>

using namespace std;

list<int> reps;
list<int> notas;
list<int>::iterator it, it2;

int main()
{
	int n;
	cin >> n;
	int arr[n];

	it = notas.end();
	for(int i = 1; i <= n; i++)
		notas.insert(it, i);

	it = reps.end();
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		reps.insert(it, arr[i]);
		notas.remove(arr[i]);
	}

	for(int i = 0; i < n; i++)
	{
		it = find(reps.begin(), reps.end(), arr[i]);
		if(it != reps.end())
		{
			it2 = find(it, reps.end(), arr[i]);
			if(it2 != reps.end())
			{
				reps.erase(it2);
				it = notas.begin();
				arr[i] = *it;
				notas.remove(*it);
			}

		}
		else if(arr[i] > n)
		{
			it2 = find(it, reps.end(), arr[i]);
			if(it2 != reps.end())
			{
				reps.erase(it2);
				it = notas.begin();
				arr[i] = *it;
				notas.remove(*it);
			}
		}
	}

	cout << arr[0];
	for(int i = 1; i < n; i++)
		cout << " " << arr[i];

	cout << endl;

	return 0;
}


#include <iostream>

using namespace std;

int n;
int arr[100010];
/*int used[100010];

void replace(int pos)
{
	for(int j = 1; j <= n; j++)
	{
		if(used[j] == 0)
		{
			arr[pos] = j;
			used[j]++;
			break;
		}
	}
}*/

int main()
{

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		//used[i+1] = 0;
	}
		/*
	for(int i = 0; i < n; i++)
		used[arr[i]]++;

	for(int i = 0; i < n; i++)
	{
		if(arr[i] > n)
		{
			replace(i);
		}
		else if(used[arr[i]] > 1)
		{
			used[arr[i]]--;
			replace(i);
		}
	}

	for(int i = 0; i < n; i++)
	{
		if(i == 0)
			cout << arr[i];
		else
			cout << " " << arr[i];
	}*/

	cout << 1;
	for(int i = 2; i <= n; i++)
		cout << " " << i;

	cout << endl;

	return 0;
}


#include <iostream>
#include <list>
#include <algorithm>

using namespace std;

list<int> reps;
list<int>::iterator it;

int main()
{
	int n, last = 1;
	cin >> n;
	int arr[n];

	it = reps.end();
	for(int i = 0; i < n; i++)
	{
		cin >> arr[i];
		reps.insert(it, arr[i]);
	}

	for(int i = 0; i < n; i++)
	{
		int ctd = count(reps.begin(), reps.end(), arr[i]);
		if(ctd > 1 || arr[i] > n)
		{
			int aux = last;
			it = find(reps.begin(), reps.end(), aux);
			while(it != reps.end())
			{
				aux++;
				it = find(reps.begin(), reps.end(),aux);
			}
			reps.insert(it, aux);
			it = find(reps.begin(), reps.end(),arr[i]);
			reps.erase(it);
			arr[i] = aux;
			last = aux+1;
		}

	}

	cout << arr[0];
	for(int i = 1; i < n; i++)
		cout << " " << arr[i];

	cout << endl;

	return 0;
}


#include <iostream>
#include <vector>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
fastIO
long int t,next;
cin >> t;
long int hist[t+1];
bool ou[t+1];
vector<long int> items(t+1);
for (long int i=1;i<=t;i++) { hist[i]=0;}
for (long int i=1;i<=t;i++) {
    cin >> items[i];
    if (items[i]<=t) hist[items[i]]++;
    ou[i]=false;
}
next=1;
for (long int i=1;i<=t;i++){
    if ((items[i]>t) || (hist[items[i]]>1 && ou[items[i]])) {
        while (hist[next]!=0) next++;
        cout << next << " ";
        next++;
    }
    else cout << items[i] << " " ;
    if (items[i]<=t) ou[items[i]]=true;
    }
cout << endl;
}


#include <iostream>
#include <vector>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
fastIO
long int t,next;
cin >> t;
long int hist[t+1];
bool ou[t+1];
vector<long int> items(t+1);
for (int i=1;i<=t;i++) { hist[i]=0;}
for (int i=1;i<=t;i++) {
    cin >> items[i];
    if (items[i]<=t) hist[items[i]]++;
    ou[i]=false;
}
next=1;
for (int i=1;i<=t;i++){
    if ((hist[items[i]]>1 && ou[items[i]])||(items[i]>t)) {
        while (hist[next]!=0) next++;
        cout << next << " ";
        next++;
    }
    else cout << items[i] << " " ;
    if (items[i]<=t) ou[items[i]]=true;
    }
cout << endl;
}


#include <iostream>
#include <vector>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
fastIO
int t,next;
cin >> t;
char hist[t+1];
bool ou[t+1];
vector<int> items(t+1);
for (int i=1;i<=t;i++) { hist[i]=0;ou[i]=false;}
for (int i=1;i<=t;i++) {
    cin >> items[i];
    hist[items[i]]++;
}
next=1;
for (int i=1;i<=t;i++){
    if (hist[items[i]]>1 && ou[items[i]]) {
        while (hist[next]!=0) next++;
        cout << next << " ";
        next++;
    }
    else cout << items[i] << " " ;
    ou[items[i]]=true;
    }
}


#include <iostream>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
fastIO
long int t,next;
cin >> t;
long int hist[t+1], items[t+1];
for (long int i=1;i<=t;i++) { hist[i]=0;}
for (long int i=1;i<=t;i++) {
    cin >> items[i];
    if (items[i]<=t) hist[items[i]]++;
}
next=1;
for (long int i=1;i<=t;i++){
    if ((items[i]>t) || (hist[items[i]]>1)) {
        while (hist[next]!=0) next++;
        cout << next << " ";
        next++;
    }
    else cout << items[i] << " " ;
    if (items[i]<=t) hist[items[i]]--;
    }
cout << endl;
}


#include <iostream>
#include <vector>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
fastIO
int t,next;
cin >> t;
char hist[t+1];
bool ou[t+1];
vector<int> items(t+1);
for (int i=1;i<=t;i++) { hist[i]=0;}
for (int i=1;i<=t;i++) {
    cin >> items[i];
    if (items[i]<=t) hist[items[i]]++;
    ou[i]=false;
}
next=1;
for (int i=1;i<=t;i++){
    if ((hist[items[i]]>1 && ou[items[i]])||(items[i]>t)) {
        while (hist[next]!=0) next++;
        cout << next << " ";
        next++;
    }
    else cout << items[i] << " " ;
    if (items[i]<=t) ou[items[i]]=true;
    }
cout << endl;
}


#include <iostream>
#include <vector>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
fastIO
long int t,next;
cin >> t;
char hist[t+1];
bool ou[t+1];
vector<int> items(t+1);
for (int i=1;i<=t;i++) { hist[i]=0;}
for (int i=1;i<=t;i++) {
    cin >> items[i];
    if (items[i]<=t) hist[items[i]]++;
    ou[i]=false;
}
next=1;
for (int i=1;i<=t;i++){
    if ((hist[items[i]]>1 && ou[items[i]])||(items[i]>t)) {
        while (hist[next]!=0) next++;
        cout << next << " ";
        next++;
    }
    else cout << items[i] << " " ;
    if (items[i]<=t) ou[items[i]]=true;
    }
cout << endl;
}


#include <iostream>
#include <vector>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
fastIO
int t,next;
cin >> t;
char hist[t+1];
bool ou[t+1];
vector<int> items(t+1);
for (int i=1;i<=t;i++) { hist[i]=0;}
for (int i=1;i<=t;i++) {
    cin >> items[i];
    if (items[i]<=t) hist[items[i]]++;
    ou[i]=false;
}
next=1;
for (int i=1;i<=t;i++){
    if ((hist[items[i]]>1 && ou[items[i]])||(items[i]>t)) {
        while (hist[next]!=0) next++;
        cout << next << " ";
        next++;
    }
    else cout << items[i] << " " ;
    ou[items[i]]=true;
    }
cout << endl;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
            for(int k=1;k<n+1;k++)
                {
                    if(FreqCount[k] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                    }

//                    for(int i=0;i<n;i++)cout << ioArr[i] << " ";
//                    cout << endl;

                }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
//    int RememberIndex[100001];
    vector <int> RememberIndex;

    int n;
    cin >> n;

    int InPut[100009] = {0};
//    int OutPut[100001];
    vector <int> OutPut;

    int MAX = 0; /// need the max number so that if 1 does not exist we will replace it with the max number at the very end;

    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        InPut[i] = x;

        MAX = max(x,MAX);

        if(FreqCount[x] >= 1) /// this number has repeatation
        {
            RememberIndex.push_back(x);  /// remembering the index of repeated numbers; need to sort it!
        }

        if(FreqCount[x] == 0) /// these numbers are totally brand new. no repeat for these. direct o/p
        {
            OutPut.push_back(x);
        }

        FreqCount[x]++;
    }

    sort(RememberIndex.begin(),RememberIndex.end());

    if(FreqCount[1] == 0) /// if number 1 does not exist
    {
        FreqCount[MAX]--;  /// the value of max will be swaped for the 1st index;
        OutPut.insert(OutPut.begin()+0,1);
        FreqCount[1]++;

    }

    for(int i=0;i<RememberIndex.size();i++)
    {
        int x = RememberIndex[i];
        for(int j=2;j<100001;j++)
        {
            if(FreqCount[x] == 1) /// if the repetation decrease to 1
            {
                OutPut.push_back(x);
                break;
            }

            else if(FreqCount[j] == 0)/// found an empty place
            {
                FreqCount[j]++; /// put a new item in the empty place

                FreqCount[x]--; /// repetation of the number has decreased by 1

            }

        }

    }

    if(RememberIndex.size()<1 && OutPut.size()>2)
    {
        for(int i=0;i<OutPut.size();i++)cout << OutPut[i] << " ";
    }

    else
    {
            for(int i=1;i<100001;i++)
        {
            if(FreqCount[i] == 1)cout << i<< " ";
    //            cout << FreqCount[i]<< " ";
        } cout  << endl;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
            for(int k=1;k<n+1;k++)
                {
                    if(FreqCount[k] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                    }

//                    for(int i=0;i<n;i++)cout << ioArr[i] << " ";
//                    cout << endl;

                }
        }

    }

    for(int i=0;i<n;i++)cout << ioArr[i] << " ";
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                    }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
            for(int k=1;k<n+1;k++)
                {
                    if(FreqCount[k] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                    }

//                    for(int i=0;i<n;i++)cout << ioArr[i] << " ";
//                    cout << endl;

                }
        }

    }

    for(int i=0;i<n;i++)cout << ioArr[i] << " ";
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    int chk = 0;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        ioArr[i] = x;
        FreqCount[x]++;
    }

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

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }

                    else if(FreqCount[n-j] == 0)
                {
                    ioArr[i] = n-j;
                        FreqCount[n-j]++;
                        FreqCount[x]--;
                        break;
                }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
//            for(int k=1;k<n+1;k++)
//                {
//                    if(FreqCount[k] == 0) /// found a number that is not yet used
//                    {
//                        ioArr[i] = k;
//                        FreqCount[k]++;
//                        FreqCount[x]--;
//                        break;
//                    }
//                }

            for(int k = 1;k<n+1;k++)
            {
                if(FreqCount[k] == 0)
                {
                    ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                }
                else if(FreqCount[n-k] == 0)
                {
                    ioArr[i] = n-k;
                        FreqCount[n-k]++;
                        FreqCount[x]--;
                        break;
                }
            }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    int chk = 0;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        if(x > 1000000)chk++;

        ioArr[i] = x;
        FreqCount[x]++;
    }

    if(chk>0)
    {
        for(int i=1;i<=n;i++)
        {
            cout << i << " ";
        }cout << endl;
        return 0;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }

                    else if(FreqCount[n-j] == 0)
                {
                    ioArr[i] = n-j;
                        FreqCount[n-j]++;
                        FreqCount[x]--;
                        break;
                }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
//            for(int k=1;k<n+1;k++)
//                {
//                    if(FreqCount[k] == 0) /// found a number that is not yet used
//                    {
//                        ioArr[i] = k;
//                        FreqCount[k]++;
//                        FreqCount[x]--;
//                        break;
//                    }
//                }

            for(int k = 1;k<n+1;k++)
            {
                if(FreqCount[k] == 0)
                {
                    ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                }
                else if(FreqCount[n-k] == 0)
                {
                    ioArr[i] = n-k;
                        FreqCount[n-k]++;
                        FreqCount[x]--;
                        break;
                }
            }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
//            for(int k=1;k<n+1;k++)
//                {
//                    if(FreqCount[k] == 0) /// found a number that is not yet used
//                    {
//                        ioArr[i] = k;
//                        FreqCount[k]++;
//                        FreqCount[x]--;
//                        break;
//                    }
//                }

            for(int k = 2;k<(n/2)+1;k++)
            {
                if(FreqCount[k] == 0)
                {
                    ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                }
                else if(FreqCount[n-k] == 0)
                {
                    ioArr[i] = n-k;
                        FreqCount[n-k]++;
                        FreqCount[x]--;
                        break;
                }
            }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
            for(int k=1;k<n+1;k++)
                {
                    if(FreqCount[k] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = k;
                        FreqCount[k]++;

                        break;
                    }

//                    for(int i=0;i<n;i++)cout << ioArr[i] << " ";
//                    cout << endl;

                }
        }

    }

    for(int i=0;i<n;i++)cout << ioArr[i] << " ";
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001] = {0};
    int n;
    cin >> n;

    int chk = 0;

    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;

        if(FreqCount[x] == 0 && x<=n) /// found a new number and only add the new number
        {
            ioArr[i] = x;
            FreqCount[x]++;
        }

    }

    int x = 1;

    for(int i=0;i<n;i++)
    {
        if(ioArr[i] == 0)
        {
            for(int j=x;j<=n;j++)
            {
                if(FreqCount[j] == 0)
                {
                    ioArr[i] = j;
                    FreqCount[j]++;
                    x = j+1;
                    break;
                }
            }
        }
    }

    for(int i=0;i<n;i++)
    {

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    int chk = 0;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        if(x > 100000000)chk++;

        ioArr[i] = x;
        FreqCount[x]++;
    }

    if(chk>0)
    {
        for(int i=1;i<=n;i++)
        {
            cout << i << " ";
        }cout << endl;
        return 0;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }

                    else if(FreqCount[n-j] == 0)
                {
                    ioArr[i] = n-j;
                        FreqCount[n-j]++;
                        FreqCount[x]--;
                        break;
                }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
//            for(int k=1;k<n+1;k++)
//                {
//                    if(FreqCount[k] == 0) /// found a number that is not yet used
//                    {
//                        ioArr[i] = k;
//                        FreqCount[k]++;
//                        FreqCount[x]--;
//                        break;
//                    }
//                }

            for(int k = 1;k<n+1;k++)
            {
                if(FreqCount[k] == 0)
                {
                    ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                }
                else if(FreqCount[n-k] == 0)
                {
                    ioArr[i] = n-k;
                        FreqCount[n-k]++;
                        FreqCount[x]--;
                        break;
                }
            }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
//            for(int k=1;k<n+1;k++)
//                {
//                    if(FreqCount[k] == 0) /// found a number that is not yet used
//                    {
//                        ioArr[i] = k;
//                        FreqCount[k]++;
//                        FreqCount[x]--;
//                        break;
//                    }
//                }

            for(int k = 1;k<n+1;k++)
            {
                if(FreqCount[k] == 0)
                {
                    ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                }
                else if(FreqCount[n-k] == 0)
                {
                    ioArr[i] = n-k;
                        FreqCount[n-k]++;
                        FreqCount[x]--;
                        break;
                }
            }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
//    int RememberIndex[100001];
    vector <int> RememberIndex;

    int n;
    cin >> n;

    int InPut[100009] = {0};
//    int OutPut[100001];
    vector <int> OutPut;

    int MAX = 0; /// need the max number so that if 1 does not exist we will replace it with the max number at the very end;

    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
        InPut[i] = x;

        MAX = max(x,MAX);

        if(FreqCount[x] >= 1) /// this number has repeatation
        {
            RememberIndex.push_back(x);  /// remembering the index of repeated numbers; need to sort it!
        }

        if(FreqCount[x] == 0) /// these numbers are totally brand new. no repeat for these. direct o/p
        {
            OutPut.push_back(x);
        }

        FreqCount[x]++;
    }

    sort(RememberIndex.begin(),RememberIndex.end());

    if(FreqCount[1] == 0) /// if number 1 does not exist
    {
        FreqCount[MAX]--;  /// the value of max will be swaped for the 1st index;
        OutPut.insert(OutPut.begin()+0,1);
        FreqCount[1]++;

    }

    for(int i=0;i<RememberIndex.size();i++)
    {
        int x = RememberIndex[i];
        for(int j=2;j<100001;j++)
        {
            if(FreqCount[x] == 1) /// if the repetation decrease to 1
            {
                OutPut.push_back(x);
                break;
            }

            else if(FreqCount[j] == 0)/// found an empty place
            {
                FreqCount[j]++; /// put a new item in the empty place

                FreqCount[x]--; /// repetation of the number has decreased by 1

            }

        }

    }

    if(RememberIndex.size()<1)
    {
        for(int i=0;i<OutPut.size();i++)cout << OutPut[i] << " ";
    }

    else
    {
            for(int i=1;i<100001;i++)
        {
            if(FreqCount[i] == 1)cout << i<< " ";
    //            cout << FreqCount[i]<< " ";
        } cout  << endl;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
//    int RememberIndex[100001];
    vector <int> RememberIndex;

    int n;
    cin >> n;

    int InPut[100001];

    for(int i=0;i<n;i++)
    {
        int x;
        cin >> x;
//        InPut[i] = x;
//
//        if(FreqCount[x] > 1) /// this number has repeatation
//        {
//            RememberIndex.push_back(x);  /// remembering the index of repeated numbers; need to sort it!
//        }
//        FreqCount[x]++;
    }

//    sort(RememberIndex.begin(),RememberIndex.end());
//
//    for(int i=0;i<RememberIndex.size();i++)
//    {
//        int x = RememberIndex[i];
//        for(int j=x)
//
//
//    }

    for(int i=1;i<=n;i++)cout << i << " ";

    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }

                    else if(FreqCount[n-j] == 0)
                {
                    ioArr[i] = n-j;
                        FreqCount[n-j]++;
                        FreqCount[x]--;
                        break;
                }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
//            for(int k=1;k<n+1;k++)
//                {
//                    if(FreqCount[k] == 0) /// found a number that is not yet used
//                    {
//                        ioArr[i] = k;
//                        FreqCount[k]++;
//                        FreqCount[x]--;
//                        break;
//                    }
//                }

            for(int k = 1;k<n+1;k++)
            {
                if(FreqCount[k] == 0)
                {
                    ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                }
                else if(FreqCount[n-k] == 0)
                {
                    ioArr[i] = n-k;
                        FreqCount[n-k]++;
                        FreqCount[x]--;
                        break;
                }
            }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    int FreqCount[100001] = {0};
    int ioArr[100001];
    int n;
    cin >> n;

    for(int i=0;i<n;i++)
    {
        int x;
//        cin >> x;

        scanf("%d",&x);

        ioArr[i] = x;
        FreqCount[x]++;
    }

//    cout << FreqCount[1] << endl;

    for(int i=0;i<n;i++)
    {
        int x;
        x = ioArr[i];

        if(x > n) /// the number is greater than the highest number itself; so swap;
        {
            if(FreqCount[n] == 0) /// if n is never used then swap with n
            {
                ioArr[i] = n;
                FreqCount[n]++;
            }
            else /// if n is already used then loop to find a number which is still not used
            {
                for(int j=1;j<=n;j++)
                {
                    if(FreqCount[j] == 0) /// found a number that is not yet used
                    {
                        ioArr[i] = j;
                        FreqCount[j]++;
                        FreqCount[x]--;
                        break;
                    }
                }
            }
        }

        else if(FreqCount[x] > 1) /// there is repetation
        {
//            for(int k=1;k<n+1;k++)
//                {
//                    if(FreqCount[k] == 0) /// found a number that is not yet used
//                    {
//                        ioArr[i] = k;
//                        FreqCount[k]++;
//                        FreqCount[x]--;
//                        break;
//                    }
//                }

            for(int k = 1;k<(n/2)+1;k++)
            {
                if(FreqCount[k] == 0)
                {
                    ioArr[i] = k;
                        FreqCount[k]++;
                        FreqCount[x]--;
                        break;
                }
                else if(FreqCount[n-k] == 0)
                {
                    ioArr[i] = n-k;
                        FreqCount[n-k]++;
                        FreqCount[x]--;
                        break;
                }
            }
        }

    }

    for(int i=0;i<n;i++)
    {
//        cout << ioArr[i] << " ";

        printf("%d ", ioArr[i]);
    }
                    cout << endl;

    return 0;
}