#include <bits/stdc++.h>
using namespace std;
int n, N;
int bit[100009], ar[1000009];
void update(int idx, int val) {
  while (idx <= n) {
    bit[idx] = max(bit[idx], val);
    idx += (idx & -idx);
  }
}
int query(int index) {
  int ans = 0;
  while (index > 0) {
    ans = max(ans, bit[index]);
    index -= index & (-index);
  }
  return ans;
}
int main() {
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    int temp = query(a);
    temp++;
    ans = max(ans, temp);
    update(a, temp);
  }
  cout << ans << endl;
}
