#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    vector<int> v = A;
    v.erase(v.begin() + i);
    int m = -1;
    for (auto &it : v) {
      chmax(m, it);
    }
    cout << m << endl;
  }
  return 0;
}
