#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 20;
int a[N];
vector<int> dp;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    int indx = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
    if (indx < dp.size())
      dp[indx] = a[i];
    else
      dp.push_back(a[i]);
  }
  cout << dp.size();
}
