#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
int a[200000], b[200000], n, m, sum = 0, ans, maxx, pos, len, seq[200000];
int f[200000] = {0};
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> a[i];
  }
  m = n;
  ans = 0;
  for (auto i : a) {
    pos = lower_bound(seq, seq + len, i) - seq;
    seq[pos] = i;
    len = max(len, pos + 1);
    f[i] = len;
  }
  cout << len;
  return 0;
}
