#include <bits/stdc++.h>
namespace AtCoder {
using Input = std::vector<std::string>;
using Num = std::vector<int>;
Input input(void) {
  Input result;
  {
    std::string buf = "", row = "";
    std::getline(std::cin, buf);
    for (unsigned int i = 0; i < buf.size(); i++) {
      if (' ' == buf[i]) {
        result.push_back(row);
        row = "";
      } else {
        row += buf[i];
      }
    }
    result.push_back(row);
  }
  return result;
}
Num replaceToInteger(Input original = {""}) {
  Num result;
  for (unsigned int i = 0; i < original.size(); i++) {
    result.push_back(atoi(original[i].c_str()));
  }
  return result;
}
}  // namespace AtCoder
namespace VecSol {
int max(std::vector<int> vec = {0}) {
  return *std::max_element(vec.begin(), vec.end());
}
unsigned int count(std::vector<int> vec = {0}, int findValue = 0) {
  return std::count(vec.begin(), vec.end(), findValue);
}
}  // namespace VecSol
int main(void) {
  AtCoder::Num s = AtCoder::replaceToInteger(AtCoder::input());
  const int n = s[0];
  int ans = 0;
  AtCoder::Num A;
  for (int i = 0; i < n; i++) {
    A.push_back(AtCoder::replaceToInteger(AtCoder::input())[0]);
  }
  for (int i = 0; i < n; i++) {
    if (1 == VecSol::count(A, A[i])) {
      ans = VecSol::max(A);
      if (ans == A[i]) {
        AtCoder::Num buf = A;
        buf.erase(buf.begin() + i);
        ans = VecSol::max(buf);
      }
    } else {
      ans = VecSol::max(A);
    }
    printf("%d\n", ans);
  }
  return 0;
}
