#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, t, j, max = 0;
  int a[200020] = {};
  char b[200020] = {};
  char c[200020] = {};
  while (~scanf("%d", &n)) {
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      b[i] = a[i] + '0';
    }
    strcpy(c, b);
    for (i = 0; i < n; i++) {
      t = b[i];
      b[i] = 0;
      sort(b, b + n);
      printf("%c\n", b[n - 1]);
      strcpy(b, c);
    }
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
  }
}
