#include <bits/stdc++.h>
using namespace std;
static int maxElement(const int* array, size_t size, int num) {
  size_t i;
  int max;
  assert(array != NULL);
  assert(size >= 1);
  max = array[0];
  for (i = 1; i <= size; ++i) {
    if (i == num) {
      continue;
    }
    if (max < array[i]) {
      max = array[i];
    }
  }
  return max;
}
int main() {
  int n;
  cin >> n;
  int v[n];
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
  }
  for (int i = 1; i <= n; i++) {
    cout << maxElement(v, n, i) << endl;
  }
}
