#include <bits/stdc++.h>
using namespace std;
void fastIOS() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
int findMax(int n, int array[], int x) {
  int max = INT_MIN;
  for (int i = 0; i < n; i++) {
    if (max < array[i] && i != x) {
      max = array[i];
    }
  }
  return max;
}
int main() {
  fastIOS();
  int n;
  cin >> n;
  int array[n];
  for (int i = 0; i < n; i++) {
    cin >> array[i];
  }
  for (int i = 0; i < n; i++) {
    cout << findMax(n, array, i) << endl;
  }
  return 0;
}
