#include <bits/stdc++.h>
int main(void) {
  long long int n, a[200010], k = 0, c = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  for (long long int i = 0; i < n; i++) {
    k = a[i];
    for (long long int j = 0; j < n; j++) {
      c = a[j];
      if (a[j] <= a[j + 1] && !a[j] == a[i]) {
        c = a[j + 1];
      }
    }
    printf("%d", c);
  }
  return 0;
}
