stdrsv1122{s1220049}76:	#include <stdio.h>
#define N 100000

int main(){
  int a[N];
  int change, n, x, i, j;

  scanf("%d", &n);
  for(j = 0; j < n; j++) scanf("%d", &a[j]);

  x = a[n - 1];
  i = -1;

  for(j = 0; j < n - 1; j++){
    if(a[j] <= x){
      i++;
      change = a[i];
      a[i] = a[j];
      a[j] = change;
    }

  }
  change = a[i + 1];
  a[i + 1] = a[n - 1];
  a[n - 1] = change;

  for(j = 0; j < n - 1; j++){
    if(j == i + 1) printf("[%d] ", a[j]);
    else printf("%d ", a[j]);
  }
  printf("%d\n", a[n - 1]);

  return 0;
}