#include <bits/stdc++.h>
int main() {
  int n;
  int max = 0;
  std::cin >> n;
  const int N = n;
  int a[N];
  for (int i = 0; i < n; i++) {
    std::cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (a[j] >= max) {
        max = a[j];
      }
    }
    std::cout << max << "\n";
    max = 0;
  }
  return 0;
}
