#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[1000], n;
  scanf("%d", &n);
  for (int i = 0; n > i; i++) scanf("%d", &a[i]);
  int dp[1001] = {};
  for (int i = 0; n > i; i++) {
    for (int j = 0; i > j; j++) {
      if (a[j] < a[i])
        dp[i] = (((dp[i]) > (dp[j] + 1)) ? (dp[i]) : (dp[j] + 1));
    }
    if (!dp[i]) dp[i] = 1;
  }
  printf("%d\n", dp[n - 1]);
}
