#include <bits/stdc++.h>
using namespace std;
long long int arr[100005];
long long int tree[4 * 100005];
long long int N = 100005 - 2;
long long int combine(long long int a, long long int b) { return max(a, b); }
void build(long long int start, long long int end, long long int node) {
  if (start == end) {
    tree[node] = arr[start];
    return;
  }
  long long int mid = (start + end) >> 1;
  build(start, mid, 2 * node);
  build(mid + 1, end, (2 * node) + 1);
  tree[node] = combine(tree[2 * node], tree[(2 * node) + 1]);
}
long long int query(long long int start, long long int end, long long int node,
                    long long int l, long long int r) {
  if (start > r || l > end) {
    return 0;
  } else if (l <= start && r >= end) {
    return tree[node];
  } else {
    long long int mid = (start + end) >> 1;
    long long int child1 = query(start, mid, 2 * node, l, r);
    long long int child2 = query(mid + 1, end, (2 * node) + 1, l, r);
    return combine(child1, child2);
  }
}
void update(long long int start, long long int end, long long int node,
            long long int idx, long long int value) {
  if (start == end) {
    tree[node] = value;
    arr[start] = value;
    return;
  }
  long long int mid = (start + end) >> 1;
  if (start <= idx && idx <= mid) {
    update(start, mid, 2 * node, idx, value);
  } else {
    update(mid + 1, end, (2 * node) + 1, idx, value);
  }
  tree[node] = combine(tree[2 * node], tree[(2 * node) + 1]);
}
int main() {
  long long int n;
  cin >> n;
  long long int ans = 1LL;
  for (long long int i = 1; i <= n; i++) {
    long long int a;
    cin >> a;
    long long int val = query(1, N, 1, 1, a);
    ans = max(ans, max(1LL, val + 1));
    update(1, N, 1, a, max(1LL, val + 1));
  }
  cout << ans << '\n';
}
