#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  vector<int> arr;
  vector<vector<int> > v;
  int temp;
  for (i = 0; i < n; i++) {
    cin >> temp;
    arr.push_back(temp);
  }
  for (i = 0; i < n; i++) {
    v.push_back(vector<int>());
    for (j = 0; j < n; j++) {
      if (j != i) {
        v[i].push_back(arr[j]);
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << *max_element(v[i].begin(), v[i].end()) << endl;
  }
}
