#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1LL << 60;
const int inf = 1e9;
int max_v(vector<int> v) {
  int max = 0;
  for (auto it = v.begin(); it != v.end(); it++) {
    max = std::max(max, *it);
  }
  return max;
}
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < (int)(N); i++) cin >> a[i];
  for (int i = 0; i < N; i++) {
    int data = a[i];
    a.erase(a.begin() + i);
    int ans = max_v(a);
    cout << ans << endl;
    a.insert(a.begin() + i, data);
  }
}
