#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> dp(1, 1000000000);
  vector<int> sequence(n);
  for (int i = 0; i < (n); i++) {
    cin >> sequence[i];
    if (dp[dp.size() - 1] > sequence[i]) {
      for (int j = 0; j < (dp.size()); j++)
        if (dp[j] > sequence[i]) {
          dp[j] = sequence[i];
          break;
        }
    } else if (dp[dp.size() - 1] < sequence[i]) {
      dp.push_back(sequence[i]);
    }
  }
  cout << dp.size() << endl;
  return 0;
}
