#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 29;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  int amax = 0;
  for (int i = 0; i < (int)(n); i++) {
    int pre = a[i];
    a[i] = 0;
    int amax = *max_element((a).begin(), (a).end());
    cout << amax << endl;
    a[i] = pre;
  }
}
