#include <bits/stdc++.h>
int max(int a, int b) {
  if (a > b) {
    return a;
  }
  return b;
}
int min(int a, int b) {
  if (a < b) {
    return a;
  }
  return b;
}
int zt(int a, int b) { return max(a, b) - min(a, b); }
int gcd(int a, int b) {
  int c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
int lcm(int a, int b) {
  int c = gcd(a, b);
  a /= c;
  return a * b;
}
int nCr(int a, int b) {
  int i, r = 1;
  for (i = 1; i <= b; i++) {
    r *= (a + 1 - i);
    r /= i;
  }
  return r;
}
int nHr(int a, int b) { return nCr(a + b - 1, b); }
int fact(int a) {
  int i, r = 1;
  for (i = 1; i <= a; i++) {
    r *= i;
  }
  return r;
}
int dsum(int x) {
  int r = 0;
  while (x) {
    r += (x % 10);
    x /= 10;
  }
  return r;
}
int dsumb(int x, int b) {
  int r = 0;
  while (x) {
    r += (x % b);
    x /= b;
  }
  return r;
}
int sankaku(int x) { return ((1 + x) * x) / 2; }
void swap(int* a, int* b) {
  int c;
  c = (*a);
  (*a) = (*b);
  (*b) = c;
}
int compareInt(const void* a, const void* b) {
  int aNum = *(int*)a;
  int bNum = *(int*)b;
  return bNum - aNum;
}
long long _gcd(long long a, long long b) {
  long long c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
long long _lcm(long long a, long long b) {
  long long c = _gcd(a, b);
  a /= c;
  return a * b;
}
int main(void) {
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < N; i++) {
    int temp = 0;
    temp = a[0];
    a[0] = a[N - 1];
    a[N - 1] = temp;
    qsort(a, N - 1, sizeof(int), compareInt);
    printf("%d\n", a[0]);
  }
}
