#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
int main() {
  int t, n, x;
  cin >> n;
  vector<pair<int, int>> arr;
  vector<int> arr2(n + 2, 0);
  set<int, greater<int>> st;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    arr2[x] = 1;
    arr.push_back(make_pair(i, x));
  }
  for (int i = 1; i < arr2.size() - 1; ++i) {
    if (arr2[i] == 0) {
      st.insert(i);
    }
  }
  sort(arr.begin(), arr.end(), sortbysec);
  for (int i = 0; i < arr.size(); ++i) {
    for (auto j = st.begin(); j != st.end(); ++j) {
      if (*j == arr[i].first) {
        if (i == 0)
          swap(arr[i].first, arr[i + 1].first);
        else
          swap(arr[i].first, arr[i - 1].first);
      }
      arr[i].second = *j;
      st.erase(j);
      break;
    }
  }
  sort(arr.begin(), arr.end());
  for (int i = 0; i < arr.size(); ++i) {
    cout << arr[i].second << " ";
  }
}
