#include <bits/stdc++.h>   using namespace std;   bool voltea;   int A[100005], B[100005], I[100005], D[100005], R[100005], ctos, hay, x, y, mid,       en;   int Z[100005], grande;   void lis() {     B[1] = A[1];     if (voltea)       D[ctos] = 1;     else       I[1] = 1;     hay = 1;     for (int i = 2; i <= ctos; i++) {       if (A[i] > B[hay]) {         ++hay;         B[hay] = A[i];         en = hay;       } else {         x = 1;         y = hay;         while (x < y) {           mid = (x + y) / 2;           if (B[mid] < A[i]) {             x = mid + 1;           } else {             y = mid;           }         }         B[x] = A[i];         en = x;       }       if (voltea) {         D[ctos - i + 1] = en;       } else {         I[i] = en;       }     }   }   int main() {     scanf( %d , &ctos);     for (int i = 1; i <= ctos; i++) {       scanf( %d , &A[i]);     }     lis();     voltea = true;     x = 1;     y = ctos;     while (x < y) {       swap(A[x], A[y]);       A[x] *= -1;       A[y] *= -1;       ++x;       --y;     }     if (x == y) {       A[x] *= -1;     }     lis();     grande = 1;     for (int i = 1; i <= ctos; i++) {       if (I[i] + D[i] - 1 > grande) {         grande = I[i] + D[i] - 1;       }     }     for (int i = 1; i <= ctos; i++) {       if (I[i] + D[i] - 1 == grande) {         Z[I[i]]++;       } else {         R[i] = 1;       }     }     for (int i = 1; i <= ctos; i++) {       if (R[i] == 0) {         R[i] = 2;         if (Z[I[i]] == 1) {           R[i] = 3;         }       }       printf( %d , R[i]);     }     printf(  n );     return 0;   }   