#include <bits/stdc++.h>
using namespace std;
int n;
struct bit {
  int v[200000];
  bit() { memset(v, 0, sizeof v); }
  int query(int p) {
    int resp = 0;
    for (int i = p; i > 0; i -= (i & (-i))) resp = max(resp, v[i]);
    return resp;
  }
  void set(int p, int val) {
    for (int i = p; i < 200000; i += (i & (-i))) v[i] = max(val, v[i]);
  }
};
int main() {
  scanf("%d", &n);
  bit bt;
  int resp = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    bt.set(x, bt.query(x - 1) + 1);
  }
  printf("%d\n", bt.query(150000));
  return 0;
}
