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