#include <bits/stdc++.h>
int main() {
  int N;
  std::cin >> N;
  std::vector<int> Ai;
  for (int i = 0; i < N; i++) {
    int temp;
    std::cin >> temp;
    Ai.push_back(temp);
  }
  for (int i = 0; i < N; i++) {
    int max = 0;
    for (int j = 0; j < N; j++) {
      int temp = Ai[j];
      if (i == j) temp = 0;
      if (temp > max) max = temp;
    }
    std::cout << max << std::endl;
  }
  return 0;
}
