#include <bits/stdc++.h>
using namespace std;
const int MX = 300000;
int n, arr[MX], bit[MX], ans = 0, lis;
void update(int x, int V) {
  while (x <= n) {
    bit[x] = max(bit[x], V);
    x += x & -x;
  }
}
int get(int x) {
  int ret = 0;
  while (x > 0) {
    ret = max(ret, bit[x]);
    x -= x & -x;
  }
  return ret;
}
int main() {
  scanf("%d", &n);
  memset(bit, 0, sizeof(bit));
  for (int j = 1; j <= n; j++) {
    scanf("%d", &arr[j]);
    lis = get(arr[j]) + 1;
    update(arr[j] + 1, lis);
    ans = max(ans, lis);
  }
  cout << ans << endl;
}
