#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cp(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (n); ++i) {
    cp = a;
    cp[i] = 0;
    sort(cp.begin(), cp.end(), greater<int>());
    cout << cp[0] << endl;
  }
  return 0;
}
