#include <bits/stdc++.h>
int main() {
  int count;
  std::cin >> count;
  int* arr = new int[count];
  for (int i = 0; i < count; i++) {
    std::cin >> arr[i];
  }
  for (int i = 0; i < count; i++) {
    int max1 = 0;
    for (int j = 0; j < count; j++) {
      if (arr[j] > max1)
        if (j != i) max1 = arr[j];
    }
    std::cout << max1 << '\n';
  }
  delete[] arr;
  return 0;
}
