#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
void disp(vector<int>& v) {
  cout << "[ ";
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << "]" << endl;
}
int main(void) {
  int n;
  cin >> n;
  vector<int> v;
  vector<int> a;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    a[i] = s;
    if (!binary_search(v.begin(), v.end(), s)) {
      v.push_back(s);
    }
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < n; i++) {
    if (a[i] != v[0]) {
      cout << v[0] << endl;
    } else if (a[i] == v[0] && v.size() <= 1) {
      cout << v[0] << endl;
    } else
      cout << v[1] << endl;
  }
  return 0;
}
