#include <bits/stdc++.h>
using namespace std;
void fastik() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
}
void solve() {}
int main() {
  fastik();
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  multiset<long long> s;
  for (int i = 0; i < (int)(n); ++i) {
    s.insert(a[i]);
  }
  for (int i = 0; i < (int)(n); ++i) {
    for (auto it = s.rbegin(); it != s.rend(); ++it) {
      long long x = *it;
      if (x != a[i]) {
        cout << x << '\n';
        break;
      } else if (x == a[i] && s.count(x) > 1) {
        cout << x << '\n';
        break;
      } else {
        continue;
      }
    }
  }
  return 0;
}
