#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846264338327950288419716939937511;
const double eps = 1e-9;
char ch_ch_ch[1 << 20];
inline string gs() {
  scanf("%s", ch_ch_ch);
  return string(ch_ch_ch);
}
inline string gl() {
  gets(ch_ch_ch);
  return string(ch_ch_ch);
}
inline int gi() {
  int x;
  scanf("%d", &x);
  return x;
}
const int inf = 1000000000;
template <typename T>
class FenwickSummator {
 private:
  T* fenv;
  int n;

 public:
  FenwickSummator(int N) {
    n = N;
    fenv = new T[N + 1];
    memset(fenv, 0, (N + 1) * sizeof(T));
  }
  void add(int p, T val) {
    if (p < 0 || p >= n) return;
    for (++p; p <= n; p += p & -p) fenv[p] = max(fenv[p], val);
  }
  T maxi(int p) {
    if (p < 0) return 0;
    if (p >= n) p = n - 1;
    T res = 0;
    for (++p; p > 0; p -= p & -p) res = max(res, fenv[p]);
    return res;
  }
  ~FenwickSummator() { delete[] fenv; }
};
int a[100100];
FenwickSummator<int> fenv(100100);
int n;
void solution() {
  n = gi();
  for (int i = 0; i < (n); ++i) a[i] = gi();
  int res = 0;
  for (int i = 0; i < (n); ++i) {
    int cur = fenv.maxi(a[i] - 1);
    fenv.add(a[i], cur + 1);
    res = max(res, cur + 1);
  }
  cout << res << endl;
}
int main(int argc, char** argv) {
  solution();
  return 0;
}
