#include<stdio.h>
#include<stdlib.h>
#define MAX 1000000

int partition(int A[], int p, int r){
  int i, j;
  x = A[r];
  i = p-1;
  for( j = p ; j < r-1 ; j++){
    if(A[j] <= x){
      i = i + 1;
      A[i] = A[j];
    }
  }
  A[i+1] = A[r];

  return i+1;
}

int main(){
 int i, j, n, q;

 scanf("%d", &n);
 for( i = 0 ; i < n ; i++ ){
   scanf("%d", &A[i]);
 }
 q = pertition(A, p, n-1);

}

