#include <bits/stdc++.h>
using namespace std;
int a[100000];
int DP[2][100000];
int main() {
  int n, res;
  cin >> n;
  for (int i = 0; i < (int)n; i++) cin >> a[i];
  for (int i = 0; i < (int)n; i++) DP[0][i] = 0;
  DP[0][0] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 0; j <= i; j++) DP[i & 1][j] = 0;
    for (int j = 0; j <= i; j++) {
      DP[i & 1][j] = max(DP[i & 1][j], DP[(i - 1) & 1][j]);
      if (a[j] < a[i]) {
        DP[i & 1][i] = max(DP[i & 1][i], DP[(i - 1) & 1][j] + 1);
      } else {
        DP[i & 1][i] = max(DP[i & 1][i], 1);
      }
    }
  }
  res = 0;
  for (int i = 0; i < n; i++) {
    res = max(res, DP[(n - 1) & 1][i]);
  }
  cout << res << endl;
  return 0;
}
