#include <bits/stdc++.h>
using namespace std;
int maxi(vector<int> arr, int n) {
  int max = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] > max) {
      max = arr[i];
    }
  }
  return max;
}
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int ctr = 0;
  vector<int> v;
  while (ctr < n) {
    for (int i = 0; i < n; i++) {
      if (i != ctr) v.push_back(arr[i]);
    }
    int ans = maxi(v, n);
    cout << ans << endl;
    v.clear();
    ctr++;
  }
}
