#include <bits/stdc++.h>
using namespace std;
int a[100000];
int P;
int getLIS() {
  int dp[100000];
  fill(dp, dp + P, INT_MAX);
  int res = 1;
  for (int j = 0; j < P; ++j) {
    for (int i = 0; i <= j; ++i) {
      if (i == 0 || dp[i - 1] < a[j]) {
        dp[i] = min(dp[i], a[j]);
        res = max(res, i + 1);
        if (dp[i] == a[j]) continue;
      }
    }
  }
  return res;
}
int main(void) {
  cin >> P;
  for (int i = 0; i < P; i++) cin >> a[i];
  cout << getLIS() << endl;
}
