#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double PI = atan(1.0);
const int N = 100001;
int n;
int tree[N * 4];
int query(int node, int l, int r, int ll, int rr) {
  if (l > rr || r < ll || r < l || rr < ll) return 0;
  if (l >= ll && r <= rr) return tree[node];
  int mid = (l + r) >> 1;
  int n1 = query(node << 1, l, mid, ll, rr);
  int n2 = query(node << 1 | 1, mid + 1, r, ll, rr);
  return max(n1, n2);
}
void insert(int node, int l, int r, int idx) {
  if (l == r) {
    tree[node] = query(1, 1, n, 1, idx - 1) + 1;
    return;
  }
  int mid = (l + r) >> 1;
  if (idx <= mid)
    insert(node << 1, l, mid, idx);
  else
    insert(node << 1 | 1, mid + 1, r, idx);
  tree[node] = max(tree[node << 1], tree[node << 1 | 1]);
}
int main() {
  ios::sync_with_stdio(0);
  ;
  cin >> n;
  memset(tree, 0, sizeof(tree));
  for (int i = 1; i <= n; i++) {
    int num;
    cin >> num;
    insert(1, 1, n, num);
  }
  cout << tree[1];
}
