#include <bits/stdc++.h>using namespace std;// To execute C++, please define "int main()"// The TestCase is shown below// Input : 1 2// Output : 3/*int main() {int n;cin>>n;vector<int> b(n);vector<int> result(n,0); int maxLen = 0;for(int i=0;i<n;i++){cin>>b[i];int l = 0;int r = maxLen;while(l < r){int mid = l + (r - l)/2;if(result[mid] < b[i]){l = mid + 1;}else {r = mid;}}result[l] = b[i]; if(l == maxLen)maxLen++;}cout<<maxLen<<endl; return 0;}*/int main(){ int n; cin>>n; vector<int> b(n); vector<int> result(n,1); int maxLen = 0; for(int i=0;i<n;i++){ cin>>b[i]; } for(int i=1;i<n;i++){ for(int j=0;j<i;j++){ if(b[i] > b[j])result[i] = max(result[j] + 1,result[i]); } } cout<<result[n-1]<<endl; return 0;}