#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int val;
};
struct Interval {
  int start, end;
};
bool compare(struct node n1, struct node n2) { return (n1.val < n2.val); }
const long long int INF = 1e15 + 3;
const long long int inf = 1e11 + 5;
const long long int maxn = 1e6 + 2;
int main() {
  vector<pair<long long, long long> > v;
  long long int n;
  cin >> n;
  long long int a[n];
  for (long long int i = 0; i < (n); ++i) {
    cin >> a[i];
    v.push_back(make_pair(a[i], i));
  }
  sort(v.begin(), v.end());
  for (long long int i = 0; i < (n); ++i) {
    if (v[n].second == i)
      cout << v[n - 1].first << endl;
    else
      cout << v[n].first << endl;
  }
  return 0;
}
