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