#include <bits/stdc++.h>
using namespace std;
int n, length = 1;
long long a[100010];
long long dp[100010];
int main(void) {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dp[i] = 10000000000L;
  }
  dp[0] = a[0];
  for (int i = 1; i < n; i++) {
    if (dp[length - 1] < a[i]) {
      dp[length++] = a[i];
    } else {
      int h = length - 1, l = 0;
      while (h > l) {
        int m = (h + l) / 2;
        if (a[i] < dp[m])
          h = m - 1;
        else if (a[i] = dp[m])
          l = m + 1;
        else
          h = l = m;
      }
      dp[l] = a[i];
    }
  }
  cout << length << endl;
  return 0;
}
