#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  int n;
  cin >> n;
  vector<int> a(n), dp(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int l = 0;
  for (int i = 0; i < n; i++) {
    int m = 0;
    for (int j = i - 1; j >= 0; j--)
      if (a[j] < a[i] && dp[j] > m) m = dp[j];
    dp[i] = m + 1;
    if (dp[i] > l) l = dp[i];
  }
  cout << l << endl;
  return 0;
}
