#include <bits/stdc++.h>
using namespace std;
#define int              long long int
#define double           long double
#define print(a)         for(auto x : a) cout << x << " "; cout << endl


const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;

inline int power(int a, int b, int mod=M) {
    int x = 1;
    a %= mod;
    while (b) {
        if (b & 1) x = (x * a) % mod; 
        a = (a * a) % mod;
        b >>= 1;
    }
    return x;
}


//_ ***************************** START Below *******************************

// 10
// 1 2 4 3 7 6 1 8 10 2


vector<int> a;


int consistency1(int n){
	vector<vector<int>> subs;
	
	for(int i=0; i<n; i++){
		int k = -1;
		int maxi = -1e18;
		
		//* Find maximum endings  where  ends < a[i]
		for(int j=0; j<subs.size(); j++){
			if(subs[j].back() < a[i] && subs[j].back() > maxi){
				maxi = subs[j].back();
				k = j;
			}
		}
		
		if(k == -1) subs.push_back({a[i]});
		else subs[k].push_back(a[i]);
	}
	
	return subs.size();
}






int consistency2(int n){
	
	multiset<int> st;
	
	for(int i=0; i<n; i++){
		auto it = st.lower_bound(a[i]);
		if(it != st.begin()){
			--it;
			st.erase(it);
		}
		st.insert(a[i]);
	}
	
	return st.size();
}















int practice(int n){


    return 0;
}





void solve() {
    
    int n;
    cin>> n;
    
    a.resize(n);
    for(int i=0; i<n; i++) cin >> a[i];
    
    cout << consistency1(n) << " " << consistency2(n) << endl;


}





int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}