#include <bits/stdc++.h>
using namespace std;
const long long mod7 = 1000000007;
const long long mod9 = 1000000009;
const int linf = 2000000000;
const long long llinf = 1000000000000000000ll;
ifstream in("series.in");
ofstream out("series.out");
int tr[400004];
int arr[100001];
int ans[100001];
int x, key;
void Set(int v, int L, int R) {
  if (L == R)
    tr[v] = key;
  else {
    int m = (L + R) / 2;
    if (m >= x)
      Set(v * 2, L, m);
    else
      Set(v * 2 + 1, m + 1, R);
    tr[v] = max(tr[v * 2], tr[v * 2 + 1]);
  }
}
int get(int v, int l, int r, int L, int R) {
  if (l > r) return 0;
  if (L == l && R == r) return tr[v];
  int m = (L + R) >> 1;
  return max(get(v * 2, l, min(m, r), L, m),
             get(v * 2 + 1, max(l, m + 1), r, m + 1, R));
}
int main() {
  int n, answer = 1;
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  for (int i = 1; i <= n; ++i) {
    x = arr[i];
    ans[i] = get(1, 1, x - 1, 1, n) + 1;
    key = ans[i];
    Set(1, 1, n);
    answer = max(ans[i], answer);
  }
  cout << answer;
  return 0;
}
