#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
long long mod(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}
int main() {
  ll n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  for (int i = 0; i < (n); i++) {
    vector<int> b;
    for (int j = 0; j < (n); j++) {
      if (j != i) b.push_back(a[j]);
    }
    sort(b.begin(), b.end());
    cout << b[n - 2] << endl;
  }
  return 0;
}
