#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double EPS = 1e-6;
int dp[100005];
static int topp;
void LIS(int x) {
  if (topp == 0)
    dp[topp++] = x;
  else if (x > dp[topp - 1])
    dp[topp++] = x;
  else {
    int left = 0, right = topp;
    while (left < right) {
      int mid = (left + right) >> 1;
      if (dp[mid] > x)
        right = mid;
      else
        left = mid + 1;
    }
    while (left < topp - 1 && dp[left] == dp[left + 1]) left++;
    dp[left] = x;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  ::topp = 0;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    LIS(a);
  }
  printf("%d\n", topp);
  return 0;
}
