#include <bits/stdc++.h>
using namespace std;
template <class V, int NV>
class SegTree {
 public:
  vector<V> val;
  static V const def = 0;
  V comp(V l, V r) { return max(l, r); };
  SegTree() { val = vector<V>(NV * 2, def); };
  V getval(int x, int y, int l = 0, int r = NV, int k = 1) {
    if (r <= x || y <= l) return def;
    if (x <= l && r <= y) return val[k];
    return comp(getval(x, y, l, (l + r) / 2, k * 2),
                getval(x, y, (l + r) / 2, r, k * 2 + 1));
  }
  void update(int entry, V v) {
    entry += NV;
    val[entry] = v;
    while (entry > 1)
      entry >>= 1, val[entry] = comp(val[entry * 2], val[entry * 2 + 1]);
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  map<int, int> zaatsu;
  for (int i = 0; i < n; i++) zaatsu[a[i]] = 0;
  int index = 0;
  for (auto p : zaatsu) {
    zaatsu[p.first] = index;
    index++;
  }
  SegTree<int, 1 << 20> st;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int _max = st.getval(0, zaatsu[a[i]]) + 1;
    ans = max(ans, _max);
    st.update(zaatsu[a[i]], ans);
  }
  cout << ans << endl;
}
