#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const double eps = 1e-8;
const long long linf = 1e18;
int a[111111], c[111111], dp[111111];
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int bsearch(int c[], int n, int a) {
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (a > c[mid] && a <= c[mid + 1])
      return mid + 1;
    else if (a < c[mid])
      r = mid - 1;
    else
      l = mid + 1;
  }
}
int LIS(int a[], int n) {
  int i, j, size = 1;
  c[1] = a[1];
  dp[1] = 1;
  for (i = 2; i <= n; ++i) {
    if (a[i] <= c[1])
      j = 1;
    else if (a[i] > c[size])
      j = ++size;
    else
      j = bsearch(c, size, a[i]);
    c[j] = a[i];
    dp[i] = j;
  }
  return size;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << LIS(a, n) << endl;
  return 0;
}
