#include <bits/stdc++.h>
using namespace std;
static const int N = 100001;
int n;
int A[N], L[N], P[N];
void lis() {
  L[0] = 0;
  A[0] = 0;
  P[0] = -1;
  int i, j, k;
  for (i = 1; i <= n; i++) {
    k = 0;
    for (j = 0; j < i; j++) {
      if (A[j] < A[i] && L[j] > L[k]) k = j;
    }
    L[i] = L[k] + 1;
    P[i] = k;
  }
}
int MAX() {
  int m = -1, i;
  for (i = 1; i <= n; i++) {
    if (m <= L[i]) m = L[i];
  }
  return m;
}
int main() {
  int i;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> A[i];
  }
  lis();
  cout << MAX() << endl;
  return 0;
}
