代码如下:
#include <iostream>
using namespace std;
const int N = 1000010;
int a[N];int find(int x) {if (a[x] != x)a[x] = find(a[x]);return a[x];
}int main() {int n;cin >> n;for (int i = 1; i <= N; i++)a[i] = i;for (int i = 1; i <= n; i++) {int x;cin >> x;x = find(x);cout << a[x] << " ";a[x] = x + 1;}return 0;
}