#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(){
    int n; cin>>n;
    deque<int> d;
    rep(i,n){
        int a; cin>>a;
        int p = lower_bound(d.begin(),d.end(),a) - d.begin();
        if(p==0) d.push_front(a);
        else d[p-1] = a;
    }
    cout << d.size() << endl;
}
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int A, B, C;
	int K;
	cin >> A >> B >> C >> K;

	int maxNum = max({ A, max({ B, C }) });
	
	if (A == maxNum) {
		for (int i = 0; i < K; i++) {
			A =  2 * A;
		}
	}
	else if (B == maxNum) {
		for (int i = 0; i < K; i++) {
			B =  2 * B;
		}
	}
	else if (C == maxNum) {
		for (int i = 0; i < K; i++) {
			C =  2 * C;
		}
	}

	cout << A + B + C << endl;
}
	
