#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<pair<int, int> > items;
  int ans = 1;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    pair<int, int> pii = make_pair(a, 0);
    vector<pair<int, int> >::iterator low =
        lower_bound(items.begin(), items.end(), pii);
    int length = 1;
    if (low != items.begin()) {
      int pos = low - items.begin();
      length = items[pos].second + 1;
    }
    ans = max(ans, length);
    pii = make_pair(a, length);
    items.insert(low, pii);
  }
  cout << ans << endl;
  return 0;
}
