#include <bits/stdc++.h>
using namespace std;
int search_max(vector<int> a, int n) {
  int max_num = a[0];
  for (int i = 0; i < a.size(); i++) {
    if (i != n) {
      if (max_num < a[i]) {
        max_num = a[i];
      }
    }
  }
  return max_num;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << search_max(a, i) << "\n";
  }
}
