#include <bits/stdc++.h>   using namespace std;   int a[100005], b[100005];   int n;   int main() {     scanf( %d n , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);     }     b[0] = -1000000;     for (int i = 1; i <= n; i++) {       b[i] = 1000000;     }     for (int i = 0; i < n; i++) {       int j = upper_bound(b, b + n, a[i]) - b;       if (b[j - 1] < a[i] && b[j] > a[i]) {         b[j] = a[i];       }     }     for (int i = n; i >= 1; i--) {       if (b[i] < 1000000) {         printf( %d n , i);         return 0;       }     }     return 0;   }   