#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a.at(i);
  vector<int> ans(n);
  for (int i = 0; i < (int)(n); i++) {
    int m = -1;
    for (int j = 0; j < (int)(n); j++) {
      if (j == i) continue;
      if (m == -1) {
        m = a.at(j);
        continue;
      }
      m = max(m, a.at(j));
    }
    ans.at(i) = m;
  }
  for (int i = 0; i < (int)(n); i++) {
    cout << ans.at(i) << endl;
  }
  return 0;
}
