#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (size_t i = 0; i < n; i++) cin >> a[i];
  int amax = 0;
  for (size_t i = 0; i < n; i++) amax = max(amax, a[i]);
  vector<vector<int>> p;
  p.resize(n);
  for (size_t i = 0; i < n; i++) p[i].resize(amax + 1);
  for (size_t i = 0; i < n; i++)
    for (size_t j = 0; j <= amax; j++) p[i][j] = 0;
  for (size_t l = 0; l < n; l++) {
    for (size_t m = 0; m <= amax; m++) p[l][m] = l == 0 ? 0 : p[l - 1][m];
    int pa = 0;
    for (size_t m = 0; m <= amax; m++) {
      if (m == a[l]) {
        p[l][m] = m == 0 ? 1 : p[l][m - 1] + 1;
        pa = p[l][m];
      }
      if (m > a[l]) p[l][m] = max(pa, p[l][m]);
    }
  }
  cout << p[n - 1][amax] << endl;
}
