#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  for (int i = 0; i < N; i++) {
    vector<int> B = A;
    B.erase(B.begin() + i);
    sort(B.begin(), B.end());
    cout << B.back() << endl;
  }
  return 0;
}
