#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, input;
  cin >> n;
  vector<int> dp(n + 2, 1e9);
  dp[0] = -1e9;
  for (int i = 0; i < n; i++) {
    cin >> input;
    for (int j = n - 1; j >= 0; j--) {
      if (dp[j] < input) {
        if (dp[j + 1] > input) dp[j + 1] = input;
        break;
      }
    }
  }
  int ans = 0;
  while (dp[ans + 1] < 1e9) {
    ++ans;
  }
  cout << ans << endl;
  return 0;
}
