#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  for (int i = 0; i < N; i++) {
    int ans = max(*max_element(A.begin(), A.begin() + i),
                  *max_element(A.begin() + i + 1, A.end()));
    cout << ans << endl;
  }
  return 0;
}
