#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int dp[101][10001];
int main() {
  int n;
  cin >> n;
  int c[100001];
  for (int i = 0; i < n; i++) cin >> c[i];
  vector<int> line;
  line.push_back(c[0]);
  int len = 1;
  int i = 1;
  while (c[i] != '\n') {
    if (*(line.end() - 1) < c[i]) {
      line.push_back(c[i]);
      len++;
    } else {
      vector<int>::iterator it = lower_bound(line.begin(), line.end(), c[i]);
      line.insert(it, c[i]);
    }
    i++;
  }
  cout << len << endl;
  return 0;
}
