#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
void nen_so(vector<int> &a) {
  set<int> s(a.begin(), a.end());
  vector<int> b(s.begin(), s.end());
  for (int &x : a) x = lower_bound(b.begin(), b.end(), x) - b.begin() + 1;
}
int bit[N], n;
void update(int pos, int x) {
  for (; pos <= n; pos += (pos & (-pos))) bit[pos] = max(bit[pos], x);
}
int get(int pos) {
  int cnt = 0;
  for (; pos > 0; pos -= (pos & (-pos))) cnt = max(cnt, bit[pos]);
  return cnt;
}
int main() {
  cin >> n;
  vector<int> a(n);
  for (int &x : a) cin >> x;
  for (int x : a) update(x, get(x - 1) + 1);
  cout << get(n);
}
