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