#include <bits/stdc++.h>
using namespace std;
int p[100100], buf[100100];
int main() {
  int ans = 1, n;
  memset(buf, 0x3f3f, sizeof(buf));
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", p + i);
  for (int i = 0; i < n; i++) {
    int j = lower_bound(buf, buf + n, p[i]) - buf;
    buf[j] = p[i];
    ans = max(ans, j + 1);
  }
  cout << ans << endl;
  return 0;
}
