#include <bits/stdc++.h>
using namespace std;
inline int ri() {
  register char c;
  while (1) {
    c = getchar();
    if (c >= '0' && c <= '9') break;
  }
  register int x = 0;
  while (1) {
    x = x * 10 + c - 48;
    c = getchar();
    if (c < '0' || c > '9') return x;
  }
}
int n, x[100010];
vector<vector<int>> s;
vector<int> cur;
int main() {
  n = ri();
  for (int i = 0; i < n; i++) x[i] = ri();
  for (int i = 0; i < n; i++) {
    auto j = lower_bound(cur.begin(), cur.end(), x[i]) - cur.begin();
    if (j == cur.size()) {
      s.push_back({});
      cur.push_back({});
    } else if (cur[j] == x[i])
      continue;
    s[j].push_back(x[i]);
    cur[j] = x[i];
  }
  cout << s.size() << "\n";
  return 0;
}
