#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)(1e6 + 11);
const int inf = (int)(1e9 + 7);
const int base = (int)(1e9 + 7);
const int mod = (int)(1e9 + 7);
const double eps = (double)(1e-9);
int n, res[maxn], a[maxn], cnt[maxn];
vector<int> v[maxn];
bool used[maxn];
int main() {
  ios_base ::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    cnt[a[i]]++;
    v[a[i]].push_back(i);
  }
  int j = 1, ans = 0;
  while (cnt[a[j]] == 1) ++j;
  for (int i = 1; i <= n; ++i) {
    if (cnt[i]) {
      if (v[i][v[i].size() - 1] < j) continue;
      int pos = (lower_bound(v[i].begin(), v[i].end(), j) - v[i].begin());
      used[v[i][pos]] = 1;
      while (used[j] || cnt[a[j]] == 1) ++j;
      continue;
    }
    ans++;
    cnt[a[j]]--;
    res[j] = i;
    ++j;
    while (used[j] || cnt[a[j]] == 1) ++j;
  }
  cout << ans << endl;
  for (int i = 1; i <= n; ++i) {
    if (!res[i]) res[i] = a[i];
    cout << res[i] << " ";
  }
  return 0;
}
