#include <bits/stdc++.h>
using namespace std;
vector<long long int> dp(200000 + 2);
int max_dp(int i, int n, vector<long long int> v) {
  v[i] = 0;
  dp[1] = v[0];
  for (int i = 2; i <= n; ++i) {
    dp[i] = max(dp[i - 1], v[i - 1]);
  }
  cout << dp[n] << endl;
}
int main() {
  long long int n = 0;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < n; ++i) {
    max_dp(i, n, v);
  }
  return 0;
}
