#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 100000 + 1;
int n;
int a[N_MAX];
bool input() {
  if (cin >> n) {
    for (int i = 0; i < n; ++i) cin >> a[i];
    return true;
  }
  return false;
}
int solve() {
  int l[n];
  fill(l, l + n, 0);
  for (int i = 0; i < n; ++i) {
    auto it = upper_bound(l, l + i, a[i], greater<int>());
    if (it == l + n) {
      l[i] = 1;
    } else {
      *it += 1;
    }
  }
  return *max_element(l, l + n);
}
int main() {
  while (input()) {
    cout << solve() << endl;
  }
  return 0;
}
