time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.

During an audit, you were surprised to find out that the items are not numbered sequentially, and some items even share the same inventory number! There is an urgent need to fix it. You have chosen to make the numbers of the items sequential, starting with 1. Changing a number is quite a time-consuming process, and you would like to make maximum use of the current numbering.

You have been given information on current inventory numbers for n items in the company. Renumber items so that their inventory numbers form a permutation of numbers from 1 to n by changing the number of as few items as possible. Let us remind you that a set of n numbers forms a permutation if all the numbers are in the range from 1 to n, and no two numbers are equal.

Input

The first line contains a single integer n — the number of items (1 ≤ n ≤ 105).

The second line contains n numbers a1, a2, …, an (1 ≤ ai ≤ 105) — the initial inventory numbers of the items.

Output

Print n numbers — the final inventory numbers of the items in the order they occur in the input. If there are multiple possible answers, you may print any of them.

Examples

input

3

1 3 2

output

1 3 2

input

4

2 2 3 3

output

2 1 3 4

input

1

2

output

1

Note

In the first test the numeration is already a permutation, so there is no need to change anything.

In the second test there are two pairs of equal numbers, in each pair you need to replace one number.

In the third test you need to replace 2 by 1, as the numbering should start from one.

【题目链接】:http://codeforces.com/contest/569/problem/B

【题解】



for 扫一遍,把没出现的数字记录下来;

for 扫一遍,把每个数字出现的次数记录下来;

for 扫一遍,如果该数字出现次数大于1,则随便把它改成一个没出现的数字;

或者该数字大于n也要改成一个没出现的数字;



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int MAXN = 1e5+10;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); int n;
int a[MAXN];
map <int,int> dic;
vector <int> g; int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);
rep1(i,1,n)
{
rei(a[i]);
dic[a[i]]++;
}
rep1(i,1,n)
if (dic[i]==0)
g.pb(i);
int len = g.size();
len--;
rep1(i,1,n)
{
int temp = dic[a[i]];
if (a[i]>n)
{
a[i] = g[len];
len--;
}
else
if (temp>1)
{
dic[a[i]]--;
a[i] = g[len];
len--;
}
}
rep1(i,1,n)
{
printf("%d",a[i]);
if (i==n) puts("");
else
printf(" ");
}
return 0;
}

最新文章

  1. Cef 架构
  2. django的序列化
  3. 用java来删除数组中指定的元素
  4. [hdu 3376]Matrix Again
  5. Google2016开发者大会
  6. php+jquery+ajax+json的一个最简单实例
  7. 【原创】编写多线程Python爬虫来过滤八戒网上的发布任务
  8. asp.net动态加载ascx用户控件
  9. 安卓中的事件分发机制之View控件
  10. 第一节:框架前期准备篇之Log4Net日志详解
  11. jQuery AJAX 方法 success()后台传来的4种数据
  12. H5实现轮播
  13. Android中使用adb访问SQLite的方法
  14. 蛋疼的经历--wireshark不能启动的问题
  15. VS2015+Python3.5的配置
  16. 【CSS】规范大纲
  17. eclipse中debug模式不能启动运行,run运行模式却能启动运行!
  18. xpath抓取的值有\r\n\t时,去掉的方法
  19. php中die(),exit(),return的区别
  20. tomcat端口被占用如何解决

热门文章

  1. 为RecyclerView添加item的点击事件
  2. Android视频播放软解与硬解的区别
  3. 给VG增加磁盘,给文件目录增加空间
  4. android 仿ios 对话框已封装成工具类
  5. 【天气APP】之桌面时钟witget组件
  6. c3p0的经常使用配置方式
  7. scrapy--介绍
  8. NHibernate之旅(3):探索查询之NHibernate查询语言(HQL)
  9. 关于pcb铺铜
  10. JS里的map与forEach遍历