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