#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<long long int> aa;
  for (long long int i = 0; i < n; i++) {
    long long int io;
    cin >> io;
    aa.push_back(io);
  }
  for (long long int i = 0; i < n; i++) {
    long long int max = 0;
    for (long long int j = 0; j < n; j++) {
      if (aa[j] > max && j != i) max = aa[j];
    }
    cout << max << endl;
  }
}
