#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T b, T p, T M) {
  long long int ret = 1;
  for (; p > 0; p >>= 1) {
    if (p & 1) ret = (ret * b) % M;
    b = (b * b) % M;
  }
  return (T)ret;
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return a * b / gcd<T>(a, b);
}
template <class T>
inline T power(T b, T p) {
  long long int x = 1;
  while (p--) x *= b;
  return x;
}
const long long int mod = 1e9 + 7;
const int siz = 202;
const long long int lim = 1e16;
int arr[100010];
int longestIncreasingSubsequence(int len) {
  vector<int> V;
  for (int i = 1; i <= len; i++) {
    int pos = upper_bound(V.begin(), V.end(), arr[i]) - V.begin();
    if (pos < V.size())
      V[pos] = arr[i];
    else
      V.push_back(arr[i]);
  }
  return V.size();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  cout << longestIncreasingSubsequence(n) << endl;
  return 0;
}
