#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> V(n);
  for (int k = 0; k < n; k++) {
    cin >> V.at(k);
  }
  for (int i = 0; i < n; i++) {
    int y = V.at(i);
    V.at(i) = -1;
    int x = *max_element(V.begin(), V.end());
    cout << x << endl;
    V.at(i) = y;
  }
}
