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