#include <bits/stdc++.h>
int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (auto& a : A) {
    std::cin >> a;
  }
  std::vector<int> result(N, 0);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i != j && result[i] < A[j]) {
        result[i] = A[j];
      }
    }
  }
  for (auto& r : result) {
    std::cout << r << std::endl;
  }
  return 0;
}
