#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265359;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
const long long N = 1e5 + 5;
bool compare(const pair<int, int>& i, const pair<int, int>& j) {
  return i.second < j.second;
}
int n, a[N];
vector<int> v;
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    if (a[i] == v[n - 1])
      cout << (v[n - 2]) << "\n";
    else
      cout << (v[n - 1]) << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
