#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n], b[n], i, j, k = 0;
  for (i = 0; i < n; i++) cin >> a[i];
  if (n < 3) {
    for (i = 0; i < n; i++) cout << a[i] << endl;
    return 0;
  }
  for (i = 0; i < n - 1; i++)
    for (j = i + 1; j < n; j++) b[k++] = a[i] > a[j] ? a[i] : a[j];
  for (i = 0; i < n; i++) cout << b[i] << endl;
  return 0;
}
