#include <bits/stdc++.h>
using namespace std;
template <class T1>
void debug(T1 e) {
  cout << e << endl;
}
template <class T1, class T2>
void debug(T1 e1, T2 e2) {
  cout << e1 << "\t" << e2 << endl;
}
template <class T1, class T2, class T3>
void debug(T1 e1, T2 e2, T3 e3) {
  cout << e1 << "\t" << e2 << "\t" << e3 << endl;
}
template <class T1, class T2, class T3, class T4>
void debug(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << endl;
}
template <class T1, class T2, class T3, class T4, class T5>
void debug(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << "\t" << e5 << endl;
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void debug(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << "\t" << e2 << "\t" << e3 << "\t" << e4 << "\t" << e5 << "\t"
       << e6 << endl;
}
template <class T>
void debug(vector<vector<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << " ";
    cout << endl;
  }
  cout << endl;
}
template <class T>
void debug(vector<basic_string<T> > e, int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j];
    cout << endl;
  }
  cout << endl;
}
template <class T>
void debug(T e[110][110], int row, int col) {
  int i, j;
  for (i = 0; i < row; i++) {
    for (j = 0; j < col; j++) cout << e[i][j] << " ";
    cout << endl;
  }
}
template <class T>
string toString(T n) {
  ostringstream oss;
  oss << n;
  oss.flush();
  return oss.str();
}
int toInt(string s) {
  int r = 0;
  istringstream sin(s);
  sin >> r;
  return r;
}
bool isVowel(char ch) {
  ch = tolower(ch);
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    return true;
  return false;
}
bool isUpper(char c) { return c >= 'A' && c <= 'Z'; }
bool isLower(char c) { return c >= 'a' && c <= 'z'; }
int heap[4 * 100010];
void update(int in, int st, int end, int x, int val) {
  if (st > x || end < x) return;
  if (st == end) {
    heap[in] = val;
    return;
  }
  int mid = (st + end) / 2;
  update(2 * in, st, mid, x, val);
  update(2 * in + 1, mid + 1, end, x, val);
  heap[in] = max(heap[2 * in], heap[2 * in + 1]);
  return;
}
int query(int in, int st, int end, int x, int y) {
  if (st > end) return 0;
  if (st > y || end < x) return 0;
  if (st >= x && end <= y) return heap[in];
  int mid = (st + end) / 2;
  int ret = query(2 * in, st, mid, x, y);
  ret = max(ret, query(2 * in + 1, mid + 1, end, x, y));
  return ret;
}
int main() {
  int n;
  while (cin >> n) {
    memset(heap, 0, sizeof(heap));
    int tem;
    int i;
    for (i = 1; i <= n; i++) {
      cin >> tem;
      update(1, 1, n, tem, query(1, 1, n, 1, tem - 1) + 1);
    }
    cout << heap[1] << endl;
  }
  return 0;
}
