#include <bits/stdc++.h>
using ll = long long;
using namespace std;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int a;
  vector<int> A;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    A.push_back(a);
  }
  vector<int> trg;
  for (int i = 0; i < N; ++i) {
    trg = A;
    trg.erase(trg.begin() + i);
    sort(trg.rbegin(), trg.rend());
    cout << trg[0] << '\n';
  }
  return 0;
}
