#include <bits/stdc++.h>
using namespace std;
int n;
int L[100000];
int dp[100000];
int LIS() {
  fill(dp, dp + n, 10000000);
  for (int i = 0; i < n; i++) {
    *lower_bound(dp, dp + n, L[i]) = L[i];
  }
  return lower_bound(dp, dp + n, 10000000) - dp;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> L[i];
  }
  cout << LIS() << "\n";
}
