#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  int h, u;
  h = 0;
  u = 0;
  if (n > 1) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < i; j++) {
        h = max(h, a[j]);
      }
      for (int j = i + 1; j < n; j++) {
        h = max(h, a[j]);
      }
      cout << h << endl;
      h = 0;
    }
  } else {
    h = a[0];
    cout << h << endl;
  }
}
