///Za n <= 20,  20 tochki
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

const int MAXN = 25;
int n,h[MAXN];

void read()
{
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> h[i];
}

bool put(int i, int j)
{
    int x = i;
    if(i > j) swap(i,j);
    for(int k = i; k <= j; k++)
    {
        if(k == x) continue;
        if(h[x] <= h[k]) return false;
    }
    return true;
}
void solve()
{
    int ans = 1;
    for(int mask = 1; mask < (1<<n); mask++)
    {
        vector<pair<int,int> >v;
        for(int j = 0; j < n; j++)
        {
            if(mask & (1<<j)) v.push_back({h[j+1],j+1});
        }
        sort(v.begin(),v.end());
        reverse(v.begin(),v.end());

        bool f = true;
        for(int i = 1; i < v.size(); i++) if(v[i-1].first == v[i].first) f = false;
        if(!f) continue;


        for(int i = 1; i < v.size(); i++)
        {
            if(!put(v[i-1].second,v[i].second)) f = false;
        }
        if(f) ans = max(ans,(int)v.size());
    }
    cout << ans << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	read();
	solve();
return 0;
}
