#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int l = 0; l < n; l++) cin >> a[l];
  for (int i = 0; i < n; i++) {
    vector<int> b(a);
    b.erase(b.begin() + i);
    int max = *max_element(b.begin(), b.end());
    cout << max << endl;
  }
  return 0;
}
