#include <bits/stdc++.h>
using namespace std;
inline void ci(void) { return; }
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest) {
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void) {
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest) {
  cout << first << " ";
  co(rest...);
  return;
}
int main() {
  int N;
  ci(N);
  vector<int> A(N), B(N);
  for (int i = (int)(0); i < (int)(N); i++) {
    ci(A.at(i));
    B.at(i) = A.at(i);
  }
  sort(B.begin(), B.end());
  for (int i = (int)(0); i < (int)(N); i++) {
    int a = 0;
    if (B.at(N - 1) == A.at(i)) {
      a = B.at(N);
    } else {
      a = B.at(N - 1);
    }
    co(a);
  }
}
