#include <bits/stdc++.h>
int main(void) {
  int n;
  std::cin >> n;
  std::vector<int> A(n);
  std::map<int, int> COUNT;
  for (int i = 0; i < n; i++) {
    std::cin >> A[i];
    if (COUNT.find(A[i]) == COUNT.end()) {
      COUNT[A[i]] = 0;
    }
    COUNT[A[i]]++;
  }
  for (int i = 0; i < n; i++) {
    auto it = COUNT.find(A[i]);
    if ((*it).second >= 2) {
      std::cout << A[i] << std::endl;
    } else {
      COUNT.erase(A[i]);
      std::cout << (*(COUNT.rbegin())).first << std::endl;
      COUNT[A[i]] = 1;
    }
  }
  return 0;
}
