#include <bits/stdc++.h>
#pragma GCC optimization("O3")
using namespace std;
const long long int N = 6999999;
int main() {
  int n, c = 0;
  cin >> n;
  vector<int> v(n), sv(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    sv[i] = v[i];
  }
  for (int i = 0; i < n; ++i) {
    sv[i] = 0;
    c = *max_element(sv.begin(), sv.end());
    cout << c << endl;
    sv[i] = v[i];
  }
  return 0;
}
