#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> mx(n);
  for (long long i = (0); i < (long long)(n); ++i) {
    cin >> a[i];
  }
  for (long long i = (0); i < (long long)(n); ++i) {
    for (long long j = (0); j < (long long)(n); ++j) {
      if (j != i) {
        mx[i] = max(mx[i], a[j]);
      }
    }
    cout << mx[i] << "\n";
    ;
  }
  cout << "\n";
  ;
  return 0;
}
