#include <bits/stdc++.h>
using namespace std;
int solve(int n, vector<int>& a);
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  cout << solve(n, a) << endl;
  return 0;
}
int solve(int n, vector<int>& a) {
  vector<int> opt(n);
  for (int i = 0; i < n; ++i) {
    int maximum = 1;
    for (int j = 0; j < i; ++j) {
      if (a[i] > a[j]) maximum = max(maximum, 1 + opt[j]);
    }
    opt[i] = maximum;
  }
  int maximum = 1;
  for (int i = 0; i < n; ++i) {
    maximum = max(maximum, opt[i]);
  }
  return maximum;
}
