#include <bits/stdc++.h>
using namespace std;
int n;
int seg[1000000];
int dp[100001];
vector<int> num;
int update(int node, int s, int e, int in, int val) {
  if (s == e) return seg[node] = val;
  int mid = (s + e) >> 1;
  if (in <= mid)
    return seg[node] = max(seg[node], update(2 * node, s, mid, in, val));
  return seg[node] = max(seg[node], update(2 * node + 1, mid + 1, e, in, val));
}
int query(int node, int s, int e, int f, int t) {
  if (s == e) return seg[node];
  if (f <= s && t >= e) return seg[node];
  int mid = (s + e) >> 1;
  if (t <= mid) return query(2 * node, s, mid, f, t);
  if (f > mid) return query(2 * node + 1, mid + 1, e, f, t);
  return max(query(2 * node, s, mid, f, t),
             query(2 * node + 1, mid + 1, e, f, t));
}
int main() {
  int n;
  cin >> n;
  num.resize(n + 1);
  for (int i = 1; i <= n; ++i) cin >> num[i];
  for (int i = 1; i <= n; ++i) {
    int res = query(1, 1, n, 1, num[i] - 1);
    dp[i] = res + 1;
    update(1, 1, n, num[i], dp[i]);
  }
  cout << query(1, 1, n, 1, n) << endl;
  return 0;
}
