#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, len = 1;
  cin >> n >> a;
  int dp[100000];
  fill_n(dp, 100000, INT_MAX / 2);
  dp[0] = a;
  for (int i = 1; i < n; i++) {
    cin >> a;
    if (dp[len - 1] < a) {
      dp[len++] = a;
    } else {
      for (int j = len; j >= 0; j--)
        if (a < dp[j]) dp[j] = a;
    }
  }
  cout << len << endl;
  return 0;
}
