#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <cassert>
#define MOD (ll)1e9 + 7
#define eps (ld)1e-30
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define sz(a) a.size()
#define loop(i, n) for(long long (i) = 0; (i) < (n) ; ++ (i))
#define loopn()
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define vii vector<int>
#define vll vector<long long>
typedef long long ll;
typedef long double ld;

using namespace std;

/*@Sergey_Miller*/

vector <vector <ll> > d;
vector <vector <ll> > dp;
vector <ll> dps;
vector <ll> h;
vector <ll> szv;
vector <vector <ll> > szst;

ll k;

void dfs2(ll v, ll st);

void dfs(ll v) {
    ll next;
    // szst[v][0] += 1;
    ll ost,add;
    dps[v] = 0;
    loop(t,sz(d[v])) {
        next = d[v][t];
        if(h[next] == -1) {
            vector <ll> cur_dp(k,0);
            vector <ll> cur_sz(k,0);
            h[next] = h[v] + 1;
            dfs(next);

            for(ll j = 1; j < k-1; ++j) {
                cur_sz[j+1] = szst[next][j];
                cur_dp[j+1] = dp[next][j];
            }

            if(k > 1) {
            cur_sz[1] = szst[next][0] + 1;
            cur_sz[0] = szst[next][k-1];
            cur_dp[0] = dp[next][k-1];
            cur_dp[1] = dp[next][0] + szst[next][0] + 1;
            } else {
                cur_sz[0] = szst[next][0] + 1;
                cur_dp[0] = dp[next][0] + szst[next][0] + 1;
            }

            loop(i,k) {
                dps[v] += cur_dp[i];
                loop(j,k) {
                    ost = i+j;

                    if(!i || !j)
                        add = 0;
                    else {
                        if(ost <= k) {
                            add = -1;
                        } else {
                            add = 0;
                        }
                    }

                    ll q;

                    q = szst[v][i] * cur_sz[j];
                    ll cur = cur_dp[j] * szst[v][i] + dp[v][i] * cur_sz[j] + add*q;
                    dps[v] += cur;
                }
            }

            for(ll j = 1; j < k-1; ++j) {
                szst[v][(j+1)] += szst[next][j];
                dp[v][(j+1)] += dp[next][j];
            }
            if(k > 1)  {
                szst[v][1] += szst[next][0] + 1;
            szst[v][0] += szst[next][k-1];
            dp[v][0] += dp[next][k-1];
            dp[v][1] += dp[next][0] + szst[next][0] + 1;
            } else {
                 szst[v][0] += szst[next][0] + 1;
                dp[v][0] += dp[next][0] + szst[next][0] + 1;
            }
        }
    }
    // dps[v]/=2;
}

void solve() {
    ll n,m;
    cin >>n >> k;
    d.resize(n);
    dp.resize(n,vector <ll> (k,0));
    h.resize(n,-1);
    szv.resize(n,0);
    szst.resize(n,vector <ll> (k,0));
    dps.resize(n,0);
    ll x,y;
    m = n-1;
    loop(i,m) {
        cin >> x >> y;
        --x;
        --y;
        d[x].pb(y);
        d[y].pb(x);
    }

    h[0] = 0;
    dfs(0);

    ll ans = 0;
    loop(i,n) {
        ans += dps[i];
    }
    cout << ans;
}

int main () {
    ios::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <cassert>
#define MOD (ll)1e9 + 7
#define eps (ld)1e-30
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define sz(a) a.size()
#define loop(i, n) for(long long (i) = 0; (i) < (n) ; ++ (i))
#define loopn()
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define vii vector<int>
#define vll vector<long long>
typedef long long ll;
typedef long double ld;

using namespace std;

/*@Sergey_Miller*/

vector <vector <ll> > d;
vector <vector <ll> > dp;
vector <ll> dps;
vector <ll> h;
vector <ll> szv;
vector <vector <ll> > szst;

ll k;

void dfs2(ll v, ll st);

void dfs(ll v) {
    ll next;
    // szst[v][0] += 1;
    ll ost,add;
    dps[v] = 0;
    loop(t,sz(d[v])) {
        next = d[v][t];
        if(h[next] == -1) {
            vector <ll> cur_dp(k,0);
            vector <ll> cur_sz(k,0);
            h[next] = h[v] + 1;
            dfs(next);

            for(ll j = 1; j < k-1; ++j) {
                cur_sz[j+1] = szst[next][j];
                cur_dp[j+1] = dp[next][j];
            }

            if(k > 1) {
            cur_sz[1] = szst[next][0] + 1;
            cur_sz[0] = szst[next][k-1];
            cur_dp[0] = dp[next][k-1];
            cur_dp[1] = dp[next][0] + szst[next][0] + 1;
            } else {
                cur_sz[0] = szst[next][0] + 1;
                cur_dp[0] = dp[next][0] + szst[next][0] + 1;
            }

            loop(i,k) {
                dps[v] += cur_dp[i];
                loop(j,k) {
                    ost = i+j;

                    if(!i || !j)
                        add = 0;
                    else {
                        if(ost <= k) {
                            add = -1;
                        } else {
                            add = 0;
                        }
                    }

                    ll q;

                    q = szst[v][i] * cur_sz[j];
                    ll cur = cur_dp[j] * szst[v][i] + dp[v][i] * cur_sz[j] + add*q;
                    dps[v] += cur;
                }
            }

            for(ll j = 1; j < k-1; ++j) {
                szst[v][(j+1)] += szst[next][j];
                dp[v][(j+1)] += dp[next][j];
            }
            if(k > 1)  {
                szst[v][1] += szst[next][0] + 1;
            szst[v][0] += szst[next][k-1];
            dp[v][0] += dp[next][k-1];
            dp[v][1] += dp[next][0] + szst[next][0] + 1;
            } else {
                 szst[v][0] += szst[next][0] + 1;
                dp[v][0] = dp[next][0] + szst[next][0] + 1;
            }
        }
    }
    // dps[v]/=2;
}

void solve() {
    ll n,m;
    cin >>n >> k;
    d.resize(n);
    dp.resize(n,vector <ll> (k,0));
    h.resize(n,-1);
    szv.resize(n,0);
    szst.resize(n,vector <ll> (k,0));
    dps.resize(n,0);
    ll x,y;
    m = n-1;
    loop(i,m) {
        cin >> x >> y;
        --x;
        --y;
        d[x].pb(y);
        d[y].pb(x);
    }

    h[0] = 0;
    dfs(0);

    ll ans = 0;
    loop(i,n) {
        ans += dps[i];
    }
    cout << ans;
}

int main () {
    ios::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <algorithm>
#include <queue>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <cassert>
#define MOD (ll)1e9 + 7
#define eps (ld)1e-30
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define sz(a) a.size()
#define loop(i, n) for(long long (i) = 0; (i) < (n) ; ++ (i))
#define loopn()
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define vii vector<int>
#define vll vector<long long>
typedef long long ll;
typedef long double ld;

using namespace std;

/*@Sergey_Miller*/

vector <vector <ll> > d;
vector <vector <ll> > dp;
vector <ll> dps;
vector <ll> h;
vector <ll> szv;
vector <vector <ll> > szst;

ll k;

void dfs2(ll v, ll st);

void dfs(ll v) {
    ll next;
    // szst[v][0] += 1;
    ll ost,add;
    dps[v] = 0;
    loop(t,sz(d[v])) {
        next = d[v][t];
        if(h[next] == -1) {
            vector <ll> cur_dp(k,0);
            vector <ll> cur_sz(k,0);
            h[next] = h[v]  +1;
            dfs(next);

            for(ll j = 1; j < k-1; ++j) {
                cur_sz[j+1] = szst[next][j];
                cur_dp[j+1] = dp[next][j];
            }

            cur_sz[1] = szst[next][0] + 1;
            cur_sz[0] = szst[next][k-1];
            cur_dp[0] = dp[next][k-1];
            cur_dp[1] = dp[next][0] + szst[next][0] + 1;

            loop(i,k) {
                dps[v] += cur_dp[i];
                loop(j,k) {
                    ost = i+j;

                    if(!i || !j)
                        add = 0;
                    else {
                        if(ost <= k) {
                            add = -1;
                        } else {
                            add = 0;
                        }
                    }

                    ll q;

                    q = szst[v][i] * cur_sz[j];
                    ll cur = cur_dp[j] * szst[v][i] + dp[v][i] * cur_sz[j] + add*q;
                    dps[v] += cur;
                }
            }

            for(ll j = 1; j < k-1; ++j) {
                szst[v][(j+1)] += szst[next][j];
                dp[v][(j+1)] += dp[next][j];
            }
            szst[v][1] += szst[next][0] + 1;
            szst[v][0] += szst[next][k-1];
            dp[v][0] += dp[next][k-1];
            dp[v][1] += dp[next][0] + szst[next][0] + 1;
        }
    }
    // dps[v]/=2;
}

void solve() {
    ll n,m;
    cin >>n >> k;
    d.resize(n);
    dp.resize(n,vector <ll> (k,0));
    h.resize(n,-1);
    szv.resize(n,0);
    szst.resize(n,vector <ll> (k,0));
    dps.resize(n,0);
    ll x,y;
    m = n-1;
    loop(i,m) {
        cin >> x >> y;
        --x;
        --y;
        d[x].pb(y);
        d[y].pb(x);
    }

    h[0] = 0;
    dfs(0);

    ll ans = 0;
    loop(i,n) {
        ans += dps[i];
    }
    cout << ans;
}

int main () {
    ios::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


#pragma GCC optimize(2)
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#define maxn 200005
#define Rint register int
#define INF 0x3f3f3f3f
using namespace std;
typedef long long lxl;

template <typename T>
inline void read(T &x)
{
	x=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	x*=f;
}

int n,k;
vector<int> G[maxn];
lxl f[maxn][6],ans;
int g[maxn][6];

inline void dfs1(int u,int fa)
{
	g[u][k]=1;
	for(auto v:G[u])
	{
		if(v==fa) continue;
		dfs1(v,u);
		for(int i=1;i<=k;++i)
			if(i==1)
			{
				f[u][i]+=f[v][k]+g[v][k];
				g[u][i]+=g[v][k];
			}
			else
			{
				f[u][i]+=f[v][i-1];
				g[u][i]+=g[v][i-1];
			}
	}
}

inline void dfs2(int u,int fa)
{
	if(u!=1)
	{
		lxl tmpf[6],tmpg[6];
		for(int i=1;i<=k;++i)
			if(i==1)
			{
				tmpf[i]=f[fa][i]-f[u][k]-g[u][k];
				tmpg[i]=g[fa][i]-g[u][k];
			}
			else
			{
				tmpf[i]=f[fa][i]-f[u][i-1];
				tmpg[i]=g[fa][i]-g[u][i-1];
			}
		for(int i=1;i<=k;++i)
		{
			if(i==1)
			{
				f[u][i]+=tmpf[k]+tmpg[k];
				g[u][i]+=tmpg[k];
			}
			else
			{
				f[u][i]+=tmpf[i-1];
				g[u][i]+=tmpg[i-1];
			}
			ans+=f[u][i];
		}
	}
	for(auto v:G[u])
	{
		if(v==fa) continue;
		dfs2(v,u);
	}
}

int main()
{
	read(n),read(k);
	for(int i=1,u,v;i<n;++i)
	{
		read(u),read(v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs1(1,0);
	for(int i=1;i<=k;++i) ans+=f[1][i];
	dfs2(1,0);
	printf("%lld\n",ans>>1);
	return 0;
}


#pragma GCC optimize(2)
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#define maxn 200005
#define Rint register int
#define INF 0x3f3f3f3f
using namespace std;
typedef long long lxl;

template <typename T>
inline void read(T &x)
{
	x=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	x*=f;
}

int n,k;
vector<int> G[maxn];
lxl f[maxn][6],ans;
int g[maxn][6];

inline void dfs1(int u,int fa)
{
	g[u][k]=1;
	for(auto v:G[u])
	{
		if(v==fa) continue;
		dfs1(v,u);
		for(int i=1;i<=k;++i)
			if(i==1)
			{
				f[u][i]+=f[v][k]+g[v][k];
				g[u][i]+=g[v][k];
			}
			else
			{
				f[u][i]+=f[v][i-1];
				g[u][i]+=g[v][i-1];
			}
	}
}

inline void dfs2(int u,int fa)
{
	if(u!=1)
	{
		lxl tmpf[6],tmpg[6];
		for(int i=1;i<=k;++i)
			if(i==1)
			{
				tmpf[i]=f[fa][i]-f[u][k]-g[u][k];
				tmpg[i]=g[fa][i]-g[u][k];
			}
			else
			{
				tmpf[i]=f[fa][i]-f[u][i-1];
				tmpg[i]=g[fa][i]-g[u][i-1];
			}
		for(int i=1;i<=k;++i)
		{
			if(i==1)
			{
				f[u][i]+=tmpf[k]+tmpg[k];
				g[u][i]+=tmpg[k];
			}
			else
			{
				f[u][i]+=tmpf[i-1];
				g[u][i]+=tmpg[i-1];
			}
			ans+=f[u][i];
		}
	}
	for(auto v:G[u])
	{
		if(v==fa) continue;
		dfs2(v,u);
	}
}

int main()
{
// 	freopen("CF771C.in","r",stdin);
	read(n),read(k);
	for(int i=1,u,v;i<n;++i)
	{
		read(u),read(v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs1(1,0);
	for(int i=1;i<=k;++i) ans+=f[1][i];
	dfs2(1,0);
	printf("%lld\n",ans>>1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
int n,k,size[200010][5];
ll dp[200010][5];
vector<int> g[200010];
void dfs(int u,int fa){
	size[u][0]=1;
	for(int v:g[u]){
		if(v==fa) continue;
		dfs(v,u);
		for(int j=0;j<k;j++){
			if(!j){
				dp[u][(j+1)%k]+=dp[v][j]+size[v][j];
				size[u][(j+1)%k]+=size[v][j];
			}else{
				dp[u][(j+1)%k]+=dp[v][j];
				size[u][(j+1)%k]+=size[v][j];
			}
		}
	}
}
ll ans;
void dfs2(int u,int fa,ll up_dp[5],int up_size[5]){
	ll nxt_dp[5]={0};
	int nxt_size[5]={0};
	for(int j=0;j<k;j++){
		if(!j){
			nxt_dp[(j+1)%k]+=up_dp[j]+up_size[j];
			nxt_size[(j+1)%k]+=up_size[j];
		}else{
			nxt_dp[(j+1)%k]+=up_dp[j];
			nxt_size[(j+1)%k]+=up_size[j];
		}
		nxt_dp[j]+=dp[u][j];
		nxt_size[j]+=size[u][j];
	}
	for(int j=0;j<k;j++)
		ans+=nxt_dp[j];
	for(int v:g[u]){
		if(v==fa) continue;
		for(int j=0;j<k;j++){
			if(!j){
				nxt_dp[(j+1)%k]-=dp[v][j]+size[v][j];
				nxt_size[(j+1)%k]-=size[v][j];
			}else{
				nxt_dp[(j+1)%k]-=dp[v][j];
				nxt_size[(j+1)%k]-=size[v][j];
			}
		}
		dfs2(v,u,nxt_dp,nxt_size);
		for(int j=0;j<k;j++){
			if(!j){
				nxt_dp[(j+1)%k]+=dp[v][j]+size[v][j];
				nxt_size[(j+1)%k]+=size[v][j];
			}else{
				nxt_dp[(j+1)%k]+=dp[v][j];
				nxt_size[(j+1)%k]+=size[v][j];
			}
		}
	}
}
int main(){
	int a,b;
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,-1);
	ll up_dp[5]={0};
	int up_size[5]={0};
	dfs2(1,-1,up_dp,up_size);
	printf("%lld\n",ans>>1);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
int n,k,size[200010][5];
ll dp[200010][5];
vector<int> g[200010];
void dfs(int u,int fa){
	size[u][0]=1;
	for(int v:g[u]){
		if(v==fa) continue;
		dfs(v,u);
		for(int j=1;j<k;j++){
			if(j>1){
				size[u][j]+=size[v][j-1];
				dp[u][j]+=dp[v][j-1];
			}else{
				size[u][j]+=size[v][j-1];
				dp[u][j]+=dp[v][j-1]+size[v][j-1];
			}
		}
		size[u][0]+=size[v][k-1];
		dp[u][0]+=dp[v][k-1];
	}
}
ll ans;
void dfs2(int u,int fa,ll up_dp[5],int up_size[5]){
	ll nxt_dp[5]={0};
	int nxt_size[5]={0};
	for(int j=1;j<k;j++){
		if(j>1){
			nxt_size[j]+=up_size[j-1];
			nxt_dp[j]+=up_dp[j-1];
		}else{
			nxt_size[j]+=up_size[j-1];
			nxt_dp[j]+=up_dp[j-1]+up_size[j-1];
		}
	}
	nxt_size[0]+=up_size[k-1];
	nxt_dp[0]+=up_dp[k-1];
	for(int j=0;j<k;j++){
		nxt_size[j]+=size[u][j];
		nxt_dp[j]+=dp[u][j];
		ans+=nxt_dp[j];
	}
	for(int v:g[u]){
		if(v==fa) continue;
		for(int j=1;j<k;j++){
			if(j>1){
				nxt_size[j]-=size[v][j-1];
				nxt_dp[j]-=dp[v][j-1];
			}else{
				nxt_size[j]-=size[v][j-1];
				nxt_dp[j]-=dp[v][j-1]+size[v][j-1];
			}
		}
		nxt_size[0]-=size[v][k-1];
		nxt_dp[0]-=dp[v][k-1];
		dfs2(v,u,nxt_dp,nxt_size);
		for(int j=1;j<k;j++){
			if(j>1){
				nxt_size[j]+=size[v][j-1];
				nxt_dp[j]+=dp[v][j-1];
			}else{
				nxt_size[j]+=size[v][j-1];
				nxt_dp[j]+=dp[v][j-1]+size[v][j-1];
			}
		}
		nxt_size[0]+=size[v][k-1];
		nxt_dp[0]+=dp[v][k-1];
	}
}
int main(){
	int a,b;
	scanf("%d%d",&n,&k);
	for(int i=1;i<n;i++){
		scanf("%d%d",&a,&b);
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(1,-1);
	ll nxt_dp[5]={0};
	int nxt_size[5]={0};
	dfs2(1,-1,nxt_dp,nxt_size);
	printf("%lld\n",ans>>1);
	return 0;
}


#include <stdio.h>
#include <vector>
using namespace std;
const int N=200050;
int Paths[5][2];
void Set(int x, int y)
{
	Paths[x][0]+=y;
	Paths[x][1]++;
}
vector<int> Tree[N];
int NodeSize[N];
bool vis[N];
void DFS(int cur, int prev, int &n)
{
	n++;
	NodeSize[cur]=1;
	int i;
	for(i=0;i<Tree[cur].size();i++)
	{
		int v=Tree[cur][i];
		if(v!=prev && !vis[v])
		{
			DFS(v,cur,n);
			NodeSize[cur]+=NodeSize[v];
		}
	}
}
int Find(int cur, int prev, int n)
{
	int i;
	for(i=0;i<Tree[cur].size();i++)
	{
		int v=Tree[cur][i];
		if(v!=prev && !vis[v])
		{
			if(NodeSize[v]>n/2) return Find(v,cur,n);
		}
	}
	return cur;
}
int Find(int src)
{
	int n=0;
	DFS(src,src,n);
	return Find(src,src,n);
}
int sol,k;
void UpdateSol(int j, int l)
{
	//sol+=(path+k-1)/k;
	int i;
	for(i=0;i<k;i++)
	{
		sol+=Paths[i][0];
		sol+=Paths[i][1]*l;
		if(j+i==0) sol+=0;
		else if(j+i<=k) sol+=Paths[i][1];
		else sol+=Paths[i][1]*2;
		//sol+=Paths[i][1]*(((path%k)+i+k-1)/k);
	}
}
vector<int> back;
//bool ok=true;
void Solve(int cur, int prev, int path)
{
	UpdateSol(path%k,path/k);
	//if(ok) printf("\n%i %i",cur,sol);
	//if(cur==4) printf("\n%i %i %i %i\n",Paths[0][0],Paths[0][1],Paths[1][0],Paths[1][1]);
	back.push_back(path);
	int i;
	for(i=0;i<Tree[cur].size();i++)
	{
		int v=Tree[cur][i];
		if(v!=prev && !vis[v])
		{
			Solve(v,cur,path+1);
		}
	}
}
void Decompose(int src)
{
	src=Find(src);
	vis[src]=true;
	int i,j;
	for(i=0;i<k;i++) Paths[i][0]=0,Paths[i][1]=0;
	Set(0,0);
	for(i=0;i<Tree[src].size();i++)
	{
		int v=Tree[src][i];
		if(!vis[v])
		{
			Solve(v,src,1);
			for(j=0;j<back.size();j++)
				Set(back[j]%k,back[j]/k);
			back.clear();
		}
	}
	//ok=false;
	//printf("%i %i\n",src,sol);
	for(i=0;i<Tree[src].size();i++)
	{
		int v=Tree[src][i];
		if(!vis[v]) Decompose(v);
	}
}
int main()
{
	int n,i,u,v;
	scanf("%i %i",&n,&k);
	for(i=1;i<n;i++)
	{
		scanf("%i %i",&u,&v);
		Tree[u].push_back(v);
		Tree[v].push_back(u);
	}
	Decompose(1);
	printf("%i\n",sol);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]<a[i+1]){ans++;}
        else{break;}
    }
    cout<<ans;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    int ans=1; int i=0;
    while((a[i]<=a[i+1]) && (i<n)){ans++;i++;}
    cout<<ans;
    return 0;
}


#include <bits\stdc++.h>
using namespace std;

int m = 1;

void rec (vector<int> v)
{
	// for (int i : v) cout << i << ' ';
	// cout << endl;

	bool sorted = true;
	for (int i = 1; i < v.size(); i++) {
		if (v[i-1] > v[i]) {
			sorted = false;
			break;
		}
	}
	if (sorted) {
		if (v.size() > m)
			m = v.size();
		return;
	}

	vector<int> s = v;
	s.erase(s.begin() + s.size()/2);

	rec(s);

	s.clear();
	for (int i = v.size()/2+1; i < v.size(); i++)
		s.push_back(v[i]);

	rec(s);
}

int main ()
{
	int n;
	cin >> n;
	vector<int> v;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}

	rec(v);

	cout << m;

	return 0;
}


#include <bits\stdc++.h>
using namespace std;

int m = 1;

void rec (vector<int> v)
{
	// for (int i : v) cout << i << ' ';
	// cout << endl;

	bool sorted = true;
	for (int i = 1; i < v.size(); i++) {
		if (v[i-1] > v[i]) {
			sorted = false;
			break;
		}
	}
	if (sorted) {
		if (v.size() > m)
			m = v.size();
		return;
	}

	rec(vector<int>(v.begin(), v.begin() + v.size() / 2));
	rec(vector<int>(v.begin() + v.size() / 2, v.end()));
}

int main ()
{
	int n;
	cin >> n;
	vector<int> v;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}

	rec(v);

	cout << m;

	return 0;
}


#include <bits\stdc++.h>
using namespace std;

void rec (vector<int> v)
{
	bool sorted = true;
	for (int i = 1; i < v.size(); i++) {
		if (v[i-1] > v[i]) {
			sorted = false;
			break;
		}
	}
	if (sorted) {
		cout << v.size();
		exit(0);
	}

	vector<int> s = v;
	s.erase(s.begin() + s.size()/2);
	rec(s);
	s.clear();
	for (int i = v.size()/2; i < v.size(); i++)
		s.push_back(v[i]);
	rec(s);
}

int main ()
{
	int n;
	cin >> n;
	vector<int> v;

	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		v.push_back(a);
	}

	rec(v);

	return 0;
}


#include <bits\stdc++.h>
using namespace std;

int a[16];

void rec (int l, int r)
{
	if (is_sorted(a + l, a + r)) {

		cout << r - l + 1;
		exit(0);
	}

	rec((l + r) / 2, r);
	rec(l, (l + r) / 2);
}

int main ()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	rec(0, n-1);

	return 0;
}


#include <bits\stdc++.h>
using namespace std;

int a[16];

bool sorted (int l, int r)
{
	for (int i = l + 1; i < r; i++) {

		if (a[i-1] > a[i])
			return false;
	}

	return true;
}

void rec (int l, int r)
{
	if (sorted(l, r)) {

		cout << r - l;
		exit(0);
	}

	rec((l + r) / 2, r);
	rec(l, (l + r) / 2);
}

int main ()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	rec(0, n);

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <set>

void sorted(const std::vector<int>& vec, int n)
{
	int res = 1, c = 1, x = 1;
	int mid = (n - 1) / 2;
	for (int i = 0; i < mid; ++i)
	{
		if (vec[i] <= vec[i + 1]) c++;
		else
			c = 1;
		if (vec[mid + i + 1] <= vec[mid + i + 2]) x++;
		else
			x = 1;
		res = std::max(x, c);
	}
	if (c + x == n) std::cout << n;
	else std::cout << res;
}

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	for (int i = 0; i < n; ++i) std::cin >> vec[i];
	sorted(vec, n);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <set>

void sorted(const std::vector<int>& vec, int n)
{
	bool is_sorted = true;
	for (int i = 0; i < n-1; ++i)
	{
		if (vec[i] > vec[i + 1]) {
			is_sorted = false;
			break;
		}
	}
	if (is_sorted)
	{
		std::cout << n;
	}
	else
	{
		int res = 0, c = 1, x = 1;
		int mid = (n - 1) / 2;
		for (int i = 0; i < mid; ++i)
		{
			if (vec[i] <= vec[i + 1]) c++;
			else
				c = 1;
			if (vec[mid + i + 1] <= vec[mid + i + 2]) x++;
			else
				x = 1;
			res = std::max(res,std::max(x, c));
		}
		std::cout << (res / 2) + 1;
	}
}

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	for (int i = 0; i < n; ++i) std::cin >> vec[i];
	sorted(vec, n);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <set>

void sorted(const std::vector<int>& vec, int n)
{
	bool is_sorted = true;
	for (int i = 0; i < n-1; ++i)
	{
		if (vec[i] > vec[i + 1]) is_sorted = false;
		break;
	}
	if (is_sorted)
	{
		std::cout << n;
	}
	else
	{
		int res = 1, c = 1, x = 1;
		int mid = (n - 1) / 2;
		for (int i = 0; i < mid; ++i)
		{
			if (vec[i] <= vec[i + 1]) c++;
			else
				c = 1;
			if (vec[mid + i + 1] <= vec[mid + i + 2]) x++;
			else
				x = 1;
			res = std::max(x, c);
		}
		std::cout << res;
	}

}

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	for (int i = 0; i < n; ++i) std::cin >> vec[i];
	sorted(vec, n);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <set>

void sorted(const std::vector<int>& vec, int n)
{
	bool is_sorted = true;
	for (int i = 0; i < n-1; ++i)
	{
		if (vec[i] > vec[i + 1]) {
			is_sorted = false;
			break;
		}
	}
	if (is_sorted)
	{
		std::cout << n;
	}
	else
	{
		int res = 0, c = 1, x = 1;
		int mid = (n - 1) / 2;
		for (int i = 0; i < mid; ++i)
		{
			if (vec[i] <= vec[i + 1]) c++;
			else
				c = 1;
			if (vec[mid + i + 1] <= vec[mid + i + 2]) x++;
			else
				x = 1;
			res = std::max(res,std::max(x, c));
		}
		if (res < 8) {
			std::cout << (res / 2) + 1;
		}
		else
		{
			std::cout << res;
		}

	}
}

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	for (int i = 0; i < n; ++i) std::cin >> vec[i];
	sorted(vec, n);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <set>

void sorted(const std::vector<int>& vec, int n)
{
	bool is_sorted = true;
	for (int i = 0; i < n-1; ++i)
	{
		if (vec[i] > vec[i + 1]) {
			is_sorted = false;
			break;
		}
	}
	if (is_sorted)
	{
		std::cout << n;
	}
	else
	{
		int res = 1, c = 1, x = 1;
		int mid = (n - 1) / 2;
		for (int i = 0; i < mid; ++i)
		{
			if (vec[i] <= vec[i + 1]) c++;
			else
				c = 1;
			if (vec[mid + i + 1] <= vec[mid + i + 2]) x++;
			else
				x = 1;
			res = std::max(x, c);
		}
		std::cout << res;
	}

}

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	for (int i = 0; i < n; ++i) std::cin >> vec[i];
	sorted(vec, n);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
#include <set>

void sorted(const std::vector<int>& vec, int n)
{
	bool is_sorted = true;
	for (int i = 0; i < n-1; ++i)
	{
		if (vec[i] > vec[i + 1]) {
			is_sorted = false;
			break;
		}
	}
	if (is_sorted)
	{
		std::cout << n;
	}
	else
	{
		int res = 0, c = 1, x = 1;
		int mid = (n - 1) / 2;
		int p1 = n / 2;
		int p2 = p1;
		for (int i = 0; i < mid; ++i)
		{
			if (vec[i] > vec[i + 1]) p1 /= 2;
			if (vec[mid + i + 1] > vec[mid + i + 2]) p2 /= 2;
		}
		std::cout << std::max(p1, p2);
	}
}

int main()
{
	int n;
	std::cin >> n;
	std::vector<int> vec(n);
	for (int i = 0; i < n; ++i) std::cin >> vec[i];
	sorted(vec, n);
	return 0;
}


#include <iostream>
using namespace std;

int main(){int n;
cin>>n;
int a[n];
int k=1;
for(int i=0;i<n;i++){cin>>a[i];}
for(int j=1;j<n;j++){
    if(a[0]<=a[j]){k++;}
    else{break;}}
 cout<<k;

}


#include <iostream>
using namespace std;

int main(){int n;
cin>>n;
int a[n];
int k=1;
for(int i=0;i<n;i++){cin>>a[i];}
for(int j=1;j<n;j++){
    if(a[0]<a[j]){k++;}
    else{break;}
} cout<<k;

}


#include <iostream>
using namespace std;

int main(){int n;
cin>>n;
int a[n];
int k=1;
for(int i=0;i<n;i++){cin>>a[i];}
for(int j=1;j<n;j++){
    if(a[0]<a[j]){k++;}}

 cout<<k;

}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;int p=1;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];

    }

    for(int j=0;j<n;j++){
        int m=1;

        fot(int k=j;k<n-1;k++){

            if(a[k]<a[k+1]){
                m++;
            }
            else{
                break;
            }
        }
        if(p<m){
            p=m;
        }

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int IG(int arr[], int n, int cnt){

    if(cnt == 0){
        return n;
    }

    int f = 0, s = 0;

    for(int i = 1; i < n/2; ++i){
        if(arr[i] < arr[i-1]){
            f++;
        }
    }

    for(int i = n/2+1; i < n; ++i){
        if(arr[i] < arr[i-1]){
            s++;
        }
    }

    if(s < f){
        return IG(arr+n/2,n/2,s);
    }
    else{
        return IG(arr,n/2,f);
    }

}

int main(){
    int n;
    cin >> n;

    int arr[n];

    for(int i = 0; i < n; ++i) cin >> arr[i];

    int cnt = 0;

    for(int i = 1; i < n; ++i){
        if(arr[i] < arr[i-1]){
            cnt ++;
        }
    }

    cout << IG(arr,n, cnt) <<endl;

}


#include <iostream>
using namespace std;

int main(){int n;
cin>>n;
int a[n];
int k=1;
for(int i=0;i<n;i++){cin>>a[i];}
for(int j=1;j<n;j++){
    if(a[0]<a[j]){k++;}

 cout<<k;

}


#include <iostream>
using namespace std;

int main(){int n;
cin>>n;
int b[n];
int k=1;
for(int i=0;i<n;i++){cin>>b[i];}
for(int j=1;j<n;j++){
    if(b[0]<=b[j]){k++;}
    else{break;}

}
 cout<<k;

}


#include <bits/stdc++.h>

using namespace std;

bool isSorted( vector <int> v, int st, int en ) {
    for( int i=st+1; i < en; i++ ) {
        if( v[i] < v[i-1] ) return false;
    }

    return true;
}

int main() {
    #ifdef sayedalmahdi
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // sayedalmahdi

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, x;
    vector <int> v, vs;

    cin >> n;
    for( int i=0; i < n; i++ ) {
        cin >> x;

        v.push_back( x );
        vs.push_back( x );
    }

    bool isInc = false;
    bool isDec = false;

    sort( vs.begin(), vs.end() );

    if( v == vs ) {
        cout << v.size() << "\n";
    }
    else {
        sort( vs.begin(), vs.end(), greater <int> () );

        if( v == vs ) {
            cout << "1\n";
        }
        else {
            if( isSorted( v, 0, n/2 ) || isSorted( v, n/2, n ) ) {
                cout << (n/2) << "\n";
            }
            else if( isSorted( v, 0, n/4 ) || isSorted( v, n/4, n/2 )
                || isSorted( v, n/2, n/4 ) || isSorted( v, n/4, n )) {
                cout << (n/4) << "\n";
            }
            else {
                for( int i=1; i < n; i++ ) {
                    if( v[i] >= v[i-1] ) {
                        cout << (n/2) << "\n";
                        return 0;
                    }
                }
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isSorted( vector <int> v, int st, int en ) {
    for( int i=st+1; i < en; i++ ) {
        if( v[i] < v[i-1] ) return false;
    }

    return true;
}

int main() {
    #ifdef sayedalmahdi
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // sayedalmahdi

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, x;
    vector <int> v, vs;

    cin >> n;
    for( int i=0; i < n; i++ ) {
        cin >> x;

        v.push_back( x );
        vs.push_back( x );
    }

    bool isInc = false;
    bool isDec = false;

    sort( vs.begin(), vs.end() );

    if( v == vs ) {
        cout << v.size() << "\n";
    }
    else {
        sort( vs.begin(), vs.end(), greater <int> () );

        if( v == vs ) {
            cout << "1\n";
        }
        else {
            if(  isSorted( v, 0, n/2 ) || isSorted( v, n/2, n ) ) {
                cout << (n/2) << "\n";
            }
            else if( isSorted( v, 0, n/4 ) || isSorted( v, n/4, n/2 )
                || isSorted( v, 0+(n/2), (n/4)+(n/2) ) || isSorted( v, (n/4)+(n/2), (n/2)+(n/2) ) ) {
                cout << (n/4) << "\n";
            }
            else {
                for( int i=1; i < n; i+=2 ) {
                    if( v[i] >= v[i-1] ) {
                        cout << (n/2) << "\n";
                        return 0;
                    }
                }
                cout << "1\n";
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isSorted( vector <int> v, int st, int en ) {
    for( int i=st+1; i < en; i++ ) {
        if( v[i] < v[i-1] ) return false;
    }

    return true;
}

int main() {
    #ifdef sayedalmahdi
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // sayedalmahdi

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, x;
    vector <int> v, vs;

    cin >> n;
    for( int i=0; i < n; i++ ) {
        cin >> x;

        v.push_back( x );
        vs.push_back( x );
    }

    bool isInc = false;
    bool isDec = false;

    sort( vs.begin(), vs.end() );

    if( v == vs ) {
        cout << v.size() << "\n";
    }
    else {
        sort( vs.begin(), vs.end(), greater <int> () );

        if( v == vs ) {
            cout << "1\n";
        }
        else {
            if( isSorted( v, 0, n/2 ) || isSorted( v, n/2, n ) ) {
                cout << (n/2) << "\n";
            }
            else if( isSorted( v, 0, n/4 ) || isSorted( v, n/4, n/2 )
                || isSorted( v, 0+(n/2), (n/4)+(n/2) ) || isSorted( v, (n/4)+(n/2), (n/2)+(n/2) ) ) {
                cout << (n/4) << "\n";
            }
            else {
                for( int i=1; i < n; i++ ) {
                    if( v[i] >= v[i-1] ) {
                        cout << (n/2) << "\n";
                        return 0;
                    }
                }
                cout << "1\n";
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isSorted( vector <int> v, int st, int en ) {
    for( int i=st+1; i < en; i++ ) {
        if( v[i] < v[i-1] ) return false;
    }

    return true;
}

int main() {
    #ifdef sayedalmahdi
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // sayedalmahdi

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, x;
    vector <int> v, vs;

    cin >> n;
    for( int i=0; i < n; i++ ) {
        cin >> x;

        v.push_back( x );
        vs.push_back( x );
    }

    bool isInc = false;
    bool isDec = false;

    sort( vs.begin(), vs.end() );

    if( v == vs ) {
        cout << v.size() << "\n";
    }
    else {
        sort( vs.begin(), vs.end(), greater <int> () );

        if( v == vs ) {
            cout << "1\n";
        }
        else {
            if( isSorted( v, 0, n/2 ) || isSorted( v, n/2, n ) ) {
                cout << (n/2) << "\n";
            }
            else if( isSorted( v, 0, n/4 ) || isSorted( v, n/4, n/2 )
                || isSorted( v, 0+(n/2), (n/4)+(n/2) ) || isSorted( v, (n/4)+(n/2), (n/2)+(n/2) ) ) {
                cout << (n/4) << "\n";
            }
            else {
                for( int i=1; i < n; i++ ) {
                    if( v[i] >= v[i-1] ) {
                        cout << (n/2) << "\n";
                        return 0;
                    }
                }
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool isSorted( vector <int> v, int st, int en ) {
    for( int i=st+1; i < en; i++ ) {
        if( v[i] < v[i-1] ) return false;
    }

    return true;
}

int main() {
    #ifdef sayedalmahdi
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // sayedalmahdi

    ios_base::sync_with_stdio(0); cin.tie(0);

    int n, x;
    vector <int> v, vs;

    cin >> n;
    for( int i=0; i < n; i++ ) {
        cin >> x;

        v.push_back( x );
        vs.push_back( x );
    }

    bool isInc = false;
    bool isDec = false;

    sort( vs.begin(), vs.end() );

    if( v == vs ) {
        cout << v.size() << "\n";
    }
    else {
        sort( vs.begin(), vs.end(), greater <int> () );

        if( v == vs ) {
            cout << "1\n";
        }
        else {
            if(  isSorted( v, 0, n/2 ) || isSorted( v, n/2, n ) ) {
                cout << (n/2) << "\n";
            }
            else if( isSorted( v, 0, n/4 ) || isSorted( v, n/4, n/2 )
                || isSorted( v, 0+(n/2), (n/4)+(n/2) ) || isSorted( v, (n/4)+(n/2), (n/2)+(n/2) ) ) {
                cout << (n/4) << "\n";
            }
            else {
                for( int i=1; i < n; i+=2 ) {
                    if( v[i] >= v[i-1] ) {
                        cout << "2\n";
                        return 0;
                    }
                }
                cout << "1\n";
            }
        }
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;

bool is_sorted(int arr1[], int first, int last){
	bool idx = true;
	for(int i=first; i<=last; i++){
		if(arr1[i]>arr1[i+1])idx=false;
	}
	return idx;
}

int main() {
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	int x = 0, y = n-1;
	int temp=8;
	int ans = 1;
	while(temp>1){
		int z=0;
		for(int i=0; i<n; i=i+temp){
//			cout<<"i:"<<i<<" "<<"temp:"<<temp<<endl;
			if(is_sorted(arr, i, ((z+1)*temp)-1)==true){
				ans = (((z+1)*temp)-1)-i+1;
//				cout<<"ans:"<<ans<<endl;
				break;
			}
			z+=1;
		}
		if(ans!=1)break;
		temp /= 2;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;

bool is_sorted(int arr1[], int first, int last){
	bool idx = true;
	for(int i=first; i<=last; i++){
		if(arr1[i]>arr1[i+1])idx=false;
	}
	return idx;
}

int main() {
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	int x = 0, y = n-1;
	int temp=n;
	int ans = 1;
	while(temp>1){
		int z=0;
		for(int i=0; i<n; i=i+temp){
//			cout<<"i:"<<i<<" "<<"temp:"<<temp<<endl;
			if(is_sorted(arr, i, ((z+1)*temp)-1)==true){
				ans = (((z+1)*temp)-1)-i+1;
//				cout<<"ans:"<<ans<<endl;
				break;
			}
			z+=1;
		}
		if(ans!=1)break;
		temp /= 2;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;

bool is_sorted(int arr1[], int first, int last){
	bool idx = true;
	for(int i=first; i<=last; i++){
		if(arr1[i]>arr1[i+1])idx=false;
	}
	return idx;
}

int main() {
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	int x = 0, y = n-1;
	int temp=8;
	int ans = 1;
	while(temp>1){
		int z=0;
		for(int i=0; i<n; i=i+temp){
			cout<<"i:"<<i<<" "<<"temp:"<<temp<<endl;
			if(is_sorted(arr, i, ((z+1)*temp)-1)==true){
				ans = (((z+1)*temp)-1)-i+1;
				cout<<"ans:"<<ans<<endl;
				break;
			}
			z+=1;
		}
		if(ans!=1)break;
		temp /= 2;
	}
	cout<<ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n;

int isArraySorted(int arr[], int n){
	if(n==1)return 1;
	else {
		int cnt=0;
		for(int i=0; i<n-1; i++){
			if(arr[i]>arr[i+1])cnt++;
		}
		if(cnt==0)return n;
		else {
			int arr1[n/2], arr2[n/2];
			for(int i=0; i<n/2; i++){
				arr1[i]=arr[i];
			}
			int j=0;
			for(int i=n/2; i<n; i++){
				arr2[j]=arr[i];
				j++;
			}
			if(isArraySorted(arr1, n/2)>=isArraySorted(arr2, n/2))return isArraySorted(arr1, n/2);
			return isArraySorted(arr2, n/2);
		}
	}
}

int main() {
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	cout<<isArraySorted(arr, n);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[16];

int comp(int l,int m)
{
    int best=0, index=1;
    for(int i=l;i<m;i++)
    {
        if(a[i]<=a[i+1])
            index++;
        else
        {
            if(index>best)
                best=index;
            index=0;
        }
    }
    return(best);
}

int max(int l,int m)
{
    if(comp(l,m)=m-l+1)
        return(m-l+1);

    int k=(l+m)/2;

    if(comp(l,k)>comp(k,m))
        m=k;
    else if(comp(l,k)<comp(k,m))
        l=k;
    else
    {
        int x=max(l,k),y=max(k,m);
        if(x>y)
            return(x);
        else
            return(y);
    }
    return(max(l,m));
}

void main()
{
    int n;
    scanf("%d",n);
    for(int i=0;i<n;i++)
        scanf("%d",a[i]);
    int l=0,m=n-1;
    printf("%d",max(l,m));
}


#include<bits/stdc++.h>
using namespace std
int a[16];

int comp(int l,int m)
{
    int best=0, index=1;
    for(int i=l;i<m;i++)
    {
        if(a[i]<=a[i+1])
            index++;
        else
        {
            if(index>best)
                best=index;
            index=0;
        }
    }
    return(best);
}

int max(int l,int m)
{
    if(comp(l,m)=m-l+1)
        return(m-l+1);

    int k=(l+m)/2;

    if(comp(l,k)>comp(k,m))
        m=k;
    else if(comp(l,k)<comp(k,m))
        l=k;
    else
    {
        int x=max(l,k),y=max(k,m);
        if(x>y)
            return(x);
        else
            return(y);
    }
    return(max(l,m));
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=0,m=n-1;
    cout<<max(l,m);
}


#include<iostream.h>

int a[16];

int comp(int l,int m)
{
    int best=0, index=1;
    for(int i=l;i<m;i++)
    {
        if(a[i]<=a[i+1])
            index++;
        else
        {
            if(index>best)
                best=index;
            index=0;
        }
    }
    return(best);
}

int max(int l,int m)
{
    if(comp(l,m)=m-l+1)
        return(m-l+1);

    int k=(l+m)/2;

    if(comp(l,k)>comp(k,m))
        m=k;
    else if(comp(l,k)<comp(k,m))
        l=k;
    else
    {
        int x=max(l,k),y=max(k,m);
        if(x>y)
            return(x);
        else
            return(y);
    }
    return(max(l,m));
}

void main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=0,m=n-1;
    cout<<max(l,m);
}


#include<bits/stdc++.h>
using namespace std;
int a[16];

int comp(int l,int m)
{
    int best=0, index=1;
    for(int i=l;i<m;i++)
    {
        if(a[i]<=a[i+1])
            index++;
        else
        {
            if(index>best)
                best=index;
            index=0;
        }
    }
    return(best);
}

int max(int l,int m)
{
    if( comp(l,m) = m-l+1)
        return(m-l+1);

    int k=(l+m)/2;

    if(comp(l,k)>comp(k,m))
        m=k;
    else if(comp(l,k)<comp(k,m))
        l=k;
    else
    {
        int x=max(l,k),y=max(k,m);
        if(x>y)
            return(x);
        else
            return(y);
    }
    return(max(l,m));
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=0,m=n-1;
    cout<<max(l,m);
}


#include<bits/stdc++.h>
using namespace std;
int a[16];

int comp(int l,int m)
{
    int best=0, index=1;
    for(int i=l;i<m;i++)
    {
        if(a[i]<=a[i+1])
            index++;
        else
        {
            if(index>best)
                best=index;
            index=0;
        }
    }
    return(best);
}

int max(int l,int m)
{
    if( comp(l,m) == m-l+1)
        return(m-l+1);

    int k=(l+m)/2;

    if(comp(l,k)>comp(k,m))
        m=k;
    else if(comp(l,k)<comp(k,m))
        l=k;
    else
    {
        int x=max(l,k),y=max(k,m);
        if(x>y)
            return(x);
        else
            return(y);
    }
    return(max(l,m));
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=0,m=n-1;
    cout<<max(l,m);
}


#include<bits/stdc++.h>
using namespace std;
int a[16];

int comp(int l,int m)
{
    int best=0, index=1;
    for(int i=l;i<m;i++)
    {
        if(a[i]<=a[i+1])
            index++;
        else
        {
            if(index>best)
                best=index;
            index=0;
        }
    }
    if(best==0)
        best=index;
    return(best);
}

int max(int l,int m)
{
    if( comp(l,m) == m-l+1 || m==l)
        return(m-l+1);

    int k=(l+m)/2;

    if(comp(l,k)>comp(k+1,m))
        m=k;
    else if(comp(l,k)<comp(k+1,m))
        l=k+1;
    else
    {
        int x=max(l,k),y=max(k+1,m);
        if(x>y)
            return(x);
        else
            return(y);
    }
    return(max(l,m));
}

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int l=0,m=n-1;
    cout<<max(l,m);
}


#include <iostream>

#include<vector>
using namespace std;

int main() {

    bool b= false;

	int n;
	cin>>n;
	vector<int> arr;
	for(int i = 0 ; i< n ;i++){
        int x;
        cin>>x;
        arr.push_back(x);
	}
	for(int i =0 ; i<n-1 ; i++){
        if(arr[i]>arr[i+1]){
            b=true;
        }
        if(b){
                if(i<n/2 +1 ){

            for(auto j = arr.begin(); j!=arr.begin()+n/2  ;j++){
                arr.erase(j);
                if(i!=0){
                i--;

                }

                b=false;

            }
                }
                else{
                     for(auto j = arr.begin()+n/2 -1  ; j!=arr.end()  ;j++){
                arr.erase(j);
                i=0;
                b=false;
                }

                }
            n=n/2 ;
            i--;
        }
	}

 cout<<arr.size();
 return 0;
}


#include<bits/stdc++.h>
using namespace std;

int arr[100];

int fnd(int begin1,int end1){
    if(is_sorted(arr+begin1,arr+end1)) return end1-begin1;
    return max(fnd(begin1,(begin1+end1)/2),fnd((begin1+end1)/2,end1));
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>arr[i];
    }
    int result=fnd(0,n);
    cout<<result<<endl;

}


#include <iostream>

#include<vector>
using namespace std;

int main() {

    bool b= false;

	int n;
	cin>>n;
	vector<int> arr;
	for(int i = 0 ; i< n ;i++){
        int x;
        cin>>x;
        arr.push_back(x);
	}
	for(int i =0 ; i<n-1 ; i++){
        if(arr[i]>arr[i+1]){
            b=true;
        }
        if(b){

            for(auto j = arr.begin(); j!=arr.begin()+n/2 ;j++){
                arr.erase(j);
                if(i!=0){
                i--;

                }

                b=false;

            }
            n=n/2 ;
            i--;
        }
	}

 cout<<arr.size();
}


#include <iostream>

#include<vector>
using namespace std;

int main() {

    bool b= false;

	int n;
	cin>>n;
	vector<int> arr;
	for(int i = 0 ; i< n ;i++){
        int x;
        cin>>x;
        arr.push_back(x);
	}
	for(int i =0 ; i<n-1 ; i++){
        if(arr[i]>arr[i+1]){
            b=true;
        }
        if(b){
                if(i<n/2 +1 ){

            for(auto j = arr.begin(); j!=arr.begin()+n/2  ;j++){
                arr.erase(j);
                if(i!=0){
                i--;

                }

                b=false;

            }
                }
                else{
                     for(auto j = arr.begin()+n/2 -1  ; j!=arr.end()  ;j++){
                arr.erase(j);
                i=0;
                b=false;
                }

                }
            n=n/2 ;
            i--;
        }
	}

 cout<<arr.size();
}


#include <iostream>

#include<vector>
using namespace std;

int main() {

    bool b= false;

	int n;
	cin>>n;
	vector<int> arr;
	for(int i = 0 ; i< n ;i++){
        int x;
        cin>>x;
        arr.push_back(x);
	}
	for(int i =0 ; i<n-1 ; i++){
        if(arr[i]>arr[i+1]){
            b=true;
        }
        if(b){
                if(i<n/2 ){

            for(auto j = arr.begin(); j!=arr.begin()+n/2 ;j++){
                arr.erase(j);
                if(i!=0){
                i--;

                }

                b=false;

            }
                }
                else{
                     for(auto j = arr.begin()+n/2 ; j!=arr.end() ;j++){
                arr.erase(j);
                i=0;
                b=false;
                }

                }
            n=n/2 ;
            i--;
        }
	}

 cout<<arr.size();
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=j=0; i<n-1; i++){
        if(a[i]>a[i+1]){
            j++;
        }
    }
    if(j==0){
        printf("%d\n",n);
    }
    else if(j==(n-1)){
        printf("%d\n",1);
    }
     else{
        printf("%d\n",j);
    }
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=j=0; i<n-1; i++){
        if(a[i]>a[i+1]){
            j++;
        }
    }
    if(j==0){
        printf("%d\n",n);
    }
    else if(j==(n-1)){
        printf("%d\n",1);
    }
    else if(j==3 && (n-1)!=3){
        printf("%d\n",2);
    }
     else{
        printf("%d\n",j);
    }
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=j=0; i<n-1; i++){
        if(a[i]>a[i+1]){
            j++;
        }
    }
    if(j==0){
        printf("%d\n",n);
    }
    else if(j==n){
        printf("%d\n",1);
    }
     else{
        printf("%d\n",j);
    }
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=j=0; i<n-1; i++){
        if(a[i]>a[i+1]){
            j++;
        }
    }
    if(j==0){
        printf("%d\n",n);
    }
    else if(j==n){
        printf("%d\n",1);
    }
    else if(j==3 && (n-1)!=3){
        printf("%d\n",4);
    }
     else{
        printf("%d\n",j);
    }
return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,n;
    scanf("%d",&n);
    int a[n];
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    for(i=j=0; i<n-1; i++){
        if(a[i]>a[i+1]){
            j++;
        }
    }
    if(j==0){
        printf("%d\n",n);
    }
    else if(j==(n-1)){
        printf("%d\n",1);
    }
    else if(j==3 && (n-1)!=3){
        printf("%d\n",4);
    }
     else{
        printf("%d\n",j);
    }
return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int fun( int i,vector<int> x,int n)
{
    int t=0,m=0,c,j;
    for(int k=0;k<n;k=k+i)
    {
      //  cout<<"k t"<<k <<t<<endl;
        m=0;
        for( j= i*t;j<(i*(t+1))-1;j++)
        {
           // cout<<j;
            if(x[j]<x[j+1])
                m++;

        }
        //cout<<endl;

        c=m+1;
        if(c!=i)
            c=0;
        if(c==i)
            break;
        t++;

    }

        return c ;

}
int main()
{
    int n,l;
    cin>>n;
    l=n;
    vector<int>arr;
    vector<int>brr;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        arr.push_back(a);
        brr.push_back(a);
    }
    sort(brr.begin(),brr.end());
    if(brr==arr)
        cout<<arr.size();
    else
    {
        int k=0,t;
       for(int i=n/2;i>=2;i=i/2)
       {
          // cout<<i;
        t=fun(i,arr,l);
          if(t>k)
            k=t;
       }
       if(k==0)
        k=1;
      cout<<k;
    }
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int fun( vector<int> x)
{
 vector<int> y;
for(int i=0;i<x.size();i++)
    y.push_back(x[i]);
    sort(y.begin(),y.end());
    if(y==x)
        return y.size();
    else
    {
        int k=0,l=0,c=0;
        for(int i=l;i<x.size()-1;i++)
        {
            if(x[i]<x[i+1])
                k++;
            else
            {
                if(c<k)
                c=k+1;
                k=0;
            }
        }
        return max(c,k+1);
    }

}
int main()
{
    int n;
    cin>>n;
    vector<int>arr;
    vector<int>brr;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        arr.push_back(a);
        brr.push_back(a);
    }
    sort(brr.begin(),brr.end());
    if(brr==arr)
        cout<<arr.size();
    else
    {
        vector<int>ar;
        vector<int>br;
        int k=n/2;
        for(int i=0;i<k;i++)
        {
            ar.push_back(arr[i]);

        }
        for(int i=k;i<arr.size();i++)
        {
            br.push_back(arr[i]);

        }
        int xx=fun(ar);
        int yy=fun(br);
        int t=max(xx,yy);
        if(t>=2 && t<4)
            t=2;
        else if(t>=4 && t<8)
            t=4;
        else if(t>=8 && t<16)
            t=8;
        else
            t=t;
        cout<<t;
    }
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int fun( vector<int> x)
{
 vector<int> y;
for(int i=0;i<x.size();i++)
    y.push_back(x[i]);
    sort(y.begin(),y.end());
    if(y==x)
        return y.size();
    else
    {
        int k=0,l=0,c=0;
        for(int i=l;i<x.size()-1;i++)
        {
            if(x[i]<x[i+1])
                k++;
            else
            {
                if(c<k)
                c=k+1;
                k=0;
            }
        }
        return max(c,k+1);
    }

}
int main()
{
    int n;
    cin>>n;
    vector<int>arr;
    vector<int>brr;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        arr.push_back(a);
        brr.push_back(a);
    }
    sort(brr.begin(),brr.end());
    if(brr==arr)
        cout<<arr.size();
    else
    {
        vector<int>ar;
        vector<int>br;
        int k=n/2;
        for(int i=0;i<k;i++)
        {
            ar.push_back(arr[i]);

        }
        for(int i=k;i<arr.size();i++)
        {
            br.push_back(arr[i]);

        }
        int xx=fun(ar);
        int yy=fun(br);
        cout<<max(xx,yy);
    }
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int fun( int i,vector<int> x,int n)
{
    int t=0,m=0,c,j;
    for(int k=0;k<n;k=k+i)
    {
      //  cout<<"k t"<<k <<t<<endl;
        m=0;
        for( j= i*t;j<(i*(t+1))-1;j++)
        {
           // cout<<j;
            if(x[j]<=x[j+1])
                m++;

        }
        //cout<<endl;

        c=m+1;
        if(c!=i)
            c=0;
        if(c==i)
            break;
        t++;

    }
    //cout<<c<<endl;
        return c ;

}
int main()
{
    int n,l;
    cin>>n;
    l=n;
    vector<int>arr;
    vector<int>brr;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        arr.push_back(a);
        brr.push_back(a);
    }
    sort(brr.begin(),brr.end());
    if(brr==arr)
        cout<<arr.size();
    else
    {
        int k=0,t;
       for(int i=n/2;i>=2;i=i/2)
       {
          // cout<<i;
        t=fun(i,arr,l);
          if(t>k)
            k=t;
       }
       if(k==0)
        k=1;
      cout<<k;
    }
}


#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int fun( int i,vector<int> x,int n)
{
    int t=0,m=0,c,j;
    for(int k=0;k<n;k=k+i)
    {
      //  cout<<"k t"<<k <<t<<endl;
        m=0;
        for( j= i*t;j<(i*(t+1))-1;j++)
        {
            cout<<j;
            if(x[j]<x[j+1])
                m++;

        }
        cout<<endl;

        c=m+1;
        if(c!=i)
            c=0;
        if(c==i)
            break;
        t++;

    }

        return c ;

}
int main()
{
    int n,l;
    cin>>n;
    l=n;
    vector<int>arr;
    vector<int>brr;
    int a;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        arr.push_back(a);
        brr.push_back(a);
    }
    sort(brr.begin(),brr.end());
    if(brr==arr)
        cout<<arr.size();
    else
    {
        int k=0,t;
       for(int i=n/2;i>=2;i=i/2)
       {
          // cout<<i;
        t=fun(i,arr,l);
          if(t>k)
            k=t;
       }
       if(k==0)
        k=1;
      cout<<k;
    }
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {

    int n;
    vector <int> a;

    cin >> n;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    int k=0,maxi=0;

    vector <int> b;

    b = a;

    sort(b.begin(),b.end());

    if(a==b) {
        cout << a.size();
        return 0;
    }

    for(int i=0;i<n/2;i++) {
        if(a[i]>a[i+1]) {
            maxi=max(maxi,k);
            k=0;
        }
        else k++;

    }

    maxi=max(maxi,k);

    k=0;
    int maxi2=0;

    for(int i=n/2-1;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            maxi2=max(maxi2,k);
            k=0;
        }
        else k++;

    }
            maxi2=max(maxi2,k);
            k=0;

    if(maxi==0 && maxi2==0) {
        cout << "1";
        return 0;
    }

    cout << max(maxi,maxi2);

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {

    int n;
    vector <int> a;

    cin >> n;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    int k=0,maxi=0;

    vector <int> b;

    b = a;

    sort(b.begin(),b.end());

    if(a==b) {
        cout << a.size();
        return 0;
    }

    for(int i=0;i<n/2-1;i++) {
        if(a[i]>a[i+1]) {
            k++;
            maxi=max(maxi,k);
            k=0;
        }
        else k++;

    }
k++;
    maxi=max(maxi,k);

    k=0;
    int maxi2=0;

    for(int i=n/2;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            k++;
            maxi2=max(maxi2,k);
            k=0;
        }
        else k++;
    }
    k++;
            maxi2=max(maxi2,k);
            k=0;

    if(maxi==0 && maxi2==0) {
        cout << "1";
        return 0;
    }

    cout << max(maxi,maxi2);

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {

    int n;
    vector <int> a;

    cin >> n;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    int k=0,maxi=0;

    vector <int> b;

    b = a;

    sort(b.begin(),b.end());

    if(a==b) {
        cout << a.size();
        return 0;
    }

    for(int i=0;i<n/2-1;i++) {
        if(a[i]>a[i+1]) {
            maxi=max(maxi,k);
            k=0;
        }
        else k++;
        if(i==n/2-2) {
            maxi=max(maxi,k);
            k=0;
        }
    }

    k=0;
    int maxi2=0;

    for(int i=n/2-1;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            maxi2=max(maxi2,k);
            k=0;
        }
        else k++;
        if(i==n/2-2) {
            maxi2=max(maxi2,k);
            k=0;
        }
    }

    if(maxi==0 && maxi2==0) {
        cout << "1";
        return 0;
    }

    cout << max(maxi,maxi2);

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {

    int n;
    vector <int> a;

    cin >> n;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    int k=0,maxi=0;

    vector <int> b;

    b = a;

    sort(b.begin(),b.end());

    if(a==b) {
        cout << a.size();
        return 0;
    }

    for(int i=0;i<n/2-1;i++) {
        if(a[i]>a[i+1]) {
            maxi=max(maxi,k);
            k=0;
        }
        else k++;

    }
k++;
    maxi=max(maxi,k);

    k=0;
    int maxi2=0;

    for(int i=n/2;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            maxi2=max(maxi2,k);
            k=0;
        }
        else k++;
    }
    k++;
            maxi2=max(maxi2,k);
            k=0;

    if(maxi==0 && maxi2==0) {
        cout << "1";
        return 0;
    }

    cout << max(maxi,maxi2);

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {

    int n;
    vector <int> a;

    cin >> n;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    int k=0,maxi=0;

    vector <int> b;

    b = a;

    sort(b.begin(),b.end());

    if(a==b) {
        cout << a.size();
        return 0;
    }

    for(int i=0;i<n/2;i++) {
        if(a[i]>a[i+1]) {
            maxi=max(maxi,k);
            k=0;
        }
        else k++;

    }

    maxi=max(maxi,k);

    k=0;
    int maxi2=0;

    for(int i=n/2;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            maxi2=max(maxi2,k);
            k=0;
        }
        else k++;

    }
            maxi2=max(maxi2,k);
            k=0;

    if(maxi==0 && maxi2==0) {
        cout << "1";
        return 0;
    }

    cout << max(maxi,maxi2);

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {

    int n;
    vector <int> a;

    cin >> n;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    int k=0,maxi=0;

    vector <int> b;

    b = a;

    sort(b.begin(),b.end());

    if(a==b) {
        cout << a.size();
        return 0;
    }

    for(int i=0;i<n/2;i++) {
        if(a[i]>a[i+1]) {
            maxi=max(maxi,k);
            k=0;
        }
        else k++;

    }

    maxi=max(maxi,k);

    k=0;
    int maxi2=0;

    for(int i=n/2;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            maxi2=max(maxi2,k);
            k=0;
        }
        else k++;
    }
    k++;
            maxi2=max(maxi2,k);
            k=0;

    if(maxi==0 && maxi2==0) {
        cout << "1";
        return 0;
    }

    cout << max(maxi,maxi2);

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {

    int n;
    vector <int> a;

    cin >> n;

    for(int i=0;i<n;i++) {
        int x;
        cin >> x;
        a.push_back(x);
    }

    int k=0,maxi=0;

    vector <int> b;

    b = a;

    sort(b.begin(),b.end());

    if(a==b) {
        cout << a.size();
        return 0;
    }

    for(int i=0;i<n/2-1;i++) {
        if(a[i]>a[i+1]) {
            k++;
            maxi=max(maxi,k);
            k=0;
        }
        else k++;

    }
k++;
    maxi=max(maxi,k);

    k=0;
    int maxi2=0;

    for(int i=n/2;i<n-1;i++) {
        if(a[i]>a[i+1]) {
            k++;
            maxi2=max(maxi2,k);
            k=0;
        }
        else k++;
    }
    k++;
            maxi2=max(maxi2,k);
            k=0;
    vector <int> c;
    c.push_back(1);
    for(int i=0;i<7;i++) {
        c.push_back(c[c.size()-1]*2);
    }

    for(int i=0;i<c.size()-2;i++) {
        if(c[i]<=max(maxi,maxi2) && c[i+1]>max(maxi,maxi2)) {
            cout << c[i];
            return 0;
        }
    }

    return 0;
}


#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second
#define forn(i, n) for(int i=0;i<n;i++)
#define fore(i, l, r) for(int i=l;i<r;i++)
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define gcd(a,b) __gcd(a,b)
#define FASTIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define sqr(x) ((x)*(x))
#define newstr cout << "\n"
#define call(a) for(auto xxx:a)cout<<xxx<<" ";cout<<"\n";
//#define FILE
const int hashP = 239017;
const int N = 1e5+10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const int INF = 1e9;
const ll INF2 = 1e18;

vector <int> a;
int maxi=0,n;

void dfs(int l, int r) {
    if(l<=r) {
        bool ok=1;
        for(int i=l;i<r;i++) {
            if(a[i]>a[i+1]) {
                ok=0;
            }
        }
        if(ok==1) maxi=max(maxi,r-l+1);
        if(r-l+1>1) {
            dfs(l,l+(r-l)/2);
            dfs(l+(r-l)/2+1,r);
        }
    }
}

int main() {

    FASTIO;

#ifdef FILE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif

    cin >> n;
    a.resize(n);
    for(auto& now : a) cin >> now;
    dfs(0,n-1);
    cout << maxi;
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#define IOS ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
int howSorted (int arr[],int size);
int* snap (int arr[],int size,int s[]){
	int	arr1[size/2],arr2[size/2],size1,size2;
	for(int i=0;i<size;i++){
		if(i<size/2)arr1[i]=arr[i];
		else arr2[i-size/2]=arr[i];
	}
	size1=howSorted(arr1,size/2);
	size2=howSorted(arr2,size/2);
	for(int i=0;i<size/2;i++){
		(size1>size2)?s[i]=arr1[i]:s[i]=arr2[i];
	}
	return s;
}
int howSorted (int arr[],int size){
	int	arr0[size],count=0;
	for(int i=0;i<size;i++){
		arr0[i]=arr[i];
	}
	sort(arr0,arr0+size);
	for(int i=0;i<size;i++){
		count++;
		if(arr0[i]!=arr[i])return count;
	}
	return count;
}
int main (){
	IOS;
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	if(n==howSorted(arr,n)){cout<<n<<endl;return 0;}
	else{
		while((n>>=1)){
			int s[n];
			snap(arr,n,s);
			if(n==howSorted(s,n)){cout<<n<<endl;return 0;}
		}
	}
	cout<<"1"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int howSorted (int arr[],int size);
int* snap (int arr[],int size,int s[]){
	int	arr1[size/2],arr2[size/2],size1,size2;
	for(int i=0;i<size;i++){
		if(i<size/2)arr1[i]=arr[i];
		else arr2[i]=arr[i];
	}
	size1=howSorted(arr1,size/2);
	size2=howSorted(arr2,size/2);
	for(int i=0;i<size/2;i++){
		(size1>size2)?s[i]=arr1[i]:s[i]=arr2[i];
	}
	return s;
}
int howSorted (int arr[],int size){
	int	arr0[size],count=0;
	for(int i=0;i<size;i++){
		arr0[i]=arr[i];
	}
	sort(arr0,arr0+size);
	for(int i=0;i<size;i++){
		count++;
		if(arr0[i]!=arr[i])return count;
	}
	return count;
}
int main (){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	if(n==howSorted(arr,n)){cout<<n<<endl;return 0;}
	else{
		while((n>>=1)){
			int s[n];
			snap(arr,n,s);
			if(n==howSorted(s,n)){cout<<n<<endl;return 0;}
		}
	}
	cout<<"1"<<endl;
	return 0;
}


    #include<bits/stdc++.h>
    using namespace std;
    int n,a[100010],i,j;
    int main()
    {
    for(cin>>n;i<n;i++)cin>>a[i];
    for(i=n;i>0;i>>=1)
    for(j=0;j<n;j+=i)
    if(is_sorted(a+j,a+j+i)){cout<<i;return 0;}
    }


#include <iostream>
#include <string>
#include <algorithm>
#define IOS ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
int howSorted (int arr[],int size);
int* snap (int arr[],int size,int s[]){
	int	arr1[size/2],arr2[size/2],size1,size2;
	for(int i=0;i<size;i++){
		if(i<size/2)arr1[i]=arr[i];
		else arr2[i]=arr[i];
	}
	size1=howSorted(arr1,size/2);
	size2=howSorted(arr2,size/2);
	for(int i=0;i<size/2;i++){
		(size1>size2)?s[i]=arr1[i]:s[i]=arr2[i];
	}
	return s;
}
int howSorted (int arr[],int size){
	int	arr0[size],count=0;
	for(int i=0;i<size;i++){
		arr0[i]=arr[i];
	}
	sort(arr0,arr0+size);
	for(int i=0;i<size;i++){
		count++;
		if(arr0[i]!=arr[i])return count;
	}
	return count;
}
int main (){
	IOS;
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	if(n==howSorted(arr,n)){cout<<n<<endl;return 0;}
	else{
		while((n>>=1)){
			int s[n];
			snap(arr,n,s);
			if(n==howSorted(s,n)){cout<<n<<endl;return 0;}
		}
	}
	cout<<"1"<<endl;
	return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#define IOS ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
int howSorted (int arr[],int size);
int* snap (int arr[],int size,int s[]){
	int	arr1[size/2],arr2[size/2],size1,size2;
	for(int i=0;i<size;i++){
		if(i<size/2)arr1[i]=arr[i];
		else arr2[i-size/2]=arr[i];
	}
	size1=howSorted(arr1,size/2);
	size2=howSorted(arr2,size/2);
	for(int i=0;i<size/2;i++){
		(size1>size2)?s[i]=arr1[i]:s[i]=arr2[i];
	}
	return s;
}
int howSorted (int arr[],int size){
	int	arr0[size],count=0;
	for(int i=0;i<size;i++){
		arr0[i]=arr[i];
	}
	sort(arr0,arr0+size);
	for(int i=0;i<size;i++){
		count++;
		if(arr0[i]!=arr[i])return count;
	}
	return count;
}
int main (){
	IOS;
	int n;
	cin>>n;
	int arr[n],ss[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
		ss[i]=arr[i];
	}
	sort(ss,ss+n,greater<>());
	for(int i=0;i<n;i++){
		if(arr[i]!=ss[i])break;
		else if(i==n-1){cout<<"1"<<endl;return 0;}
	}
	if(n==howSorted(arr,n)){cout<<n<<endl;return 0;}
	else{
		while((n>>=1)&&n){
			if(n==1){cout<<"1"<<endl;return 0;}
			int s[n];
			snap(arr,n,s);
			if(n==howSorted(s,n)){cout<<n<<endl;return 0;}
		}
	}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=2e5+5;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll pow_mod(ll a,ll b,ll mod)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
			res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
int a[20];
int main()
{
	IO;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int cnt=0,ans=0,maxx=0;
	for(int i=1;i<=n;i=i*2)
	{
		maxx=1;
		cnt=0;
		for(int s=1,e=i;e<=n;s+=i,e+=i)
		{
			for(int k=s;k<=e;k++)
			{
				if(a[k-1]<=a[k])
				{
					cnt++;
					maxx=max(maxx,cnt);
				}
				else
					cnt=0;

			}
			if(maxx==i)
				ans=max(maxx,ans);

		 }

	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=2e5+5;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll pow_mod(ll a,ll b,ll mod)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
			res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
int a[20];
int main()
{
	IO;
	int n;
	cin>>n;
	a[0]=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int maxx=0,cnt=0;
	for(int i=n;i>=1;i=i/2)
	{
		cnt=0;
		for(int j=1;j<=i;j++)
		{
			if(a[j-1]>a[j])
			{
				cnt=0;
				break;
			}
			else
			{
				cnt++;
			}
		}
		if(cnt!=i)
			maxx=0;
		else
		{
			maxx=cnt;
			break;
		}
	}
	cout<<maxx<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=2e5+5;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll pow_mod(ll a,ll b,ll mod)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
			res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
int a[20];
int main()
{
	IO;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int cnt=0,ans=0,maxx=0;
	for(int i=1;i<=n;i=i*2)
	{
		maxx=0;
		cnt=0;
		for(int s=1,e=i;e<=n;s+=i,e+=i)
		{
			for(int k=s;k<=e;k++)
			{
				if(a[k-1]<=a[k])
				{
					cnt++;
					maxx=max(maxx,cnt);
				}
				else
					cnt=0;

			}
			if(maxx==i)
					ans=max(maxx,ans);

		 }

	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=2e5+5;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll pow_mod(ll a,ll b,ll mod)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
			res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
int a[20];
int main()
{
	IO;
	int n;
	cin>>n;
	a[0]=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int maxx=0,cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i-1]<=a[i])
		{
			cnt++;
			maxx=max(maxx,cnt);
		}
		else
			cnt=0;
	}
	int flag=0;
	for(int i=16;i>=1;i=i/2)
	{
		if(maxx>=i)
		{
			flag=i;
			break;
		}

	}
	cout<<flag<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=2e5+5;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll pow_mod(ll a,ll b,ll mod)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
			res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
int a[20];
int main()
{
	IO;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int cnt=0,ans=0,maxx=0;
	for(int i=1;i<=n;i=i*2)
	{

		maxx=0;
		for(int s=1,e=i;e<=n;s+=i,e+=i)
		{
			cnt=0;
			for(int k=s;k<=e;k++)
			{
				if(a[k-1]<=a[k])
				{
					cnt++;
					maxx=max(maxx,cnt);
				}
				else
					cnt=0;

			}
			if(maxx==i)
				ans=max(maxx,ans);

		 }

	}
	cout<<ans<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=2e5+5;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll pow_mod(ll a,ll b,ll mod)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
			res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
int a[20];
int main()
{
	IO;
	int n;
	cin>>n;
	a[0]=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int maxx=0,cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i-1]<a[i])
		{
			cnt++;
			maxx=max(maxx,cnt);
		}
		else
			cnt=0;
	}
	int flag=0;
	for(int i=16;i>=1;i=i/2)
	{
		if(maxx>=i)
		{
			flag=i;
			break;
		}

	}
	cout<<flag<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>

using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll inf=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const int maxn=2e5+5;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll pow_mod(ll a,ll b,ll mod)
{
	ll res=1;
	while(b!=0)
	{
		if(b&1)
			res=res*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return res;
}
int a[20];
int main()
{
	IO;
	int n;
	cin>>n;
	a[0]=0;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int maxx=0,cnt=0;
	for(int i=n;i>=1;i=i/2)
	{
		cnt=0;
		for(int j=1;j<=i;j++)
		{
			if(a[j-1]>a[j])
			{
				cnt=0;
				break;
			}
			else
			{
				cnt++;
			}
		}
		maxx=max(cnt,maxx);
	}
	cout<<maxx<<endl;
	return 0;
}


#include <iostream>

using namespace std;

int main(){
	cout << "Hello World!";

	return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	int array[n];
	int newarray[n];
    for(int i = 0; i < n; ++i){
		cin >> array[i];
		newarray[i] = array[i];
	}

	bool isSorted = false;

	while(!isSorted){
		for(int i = 1; i < n; ++i){
			if(array[i-1]<=array[i]){
				isSorted = true;
			}
			else{
				isSorted = false;
				break;
			}
		}

		if(!isSorted){
			n /= 2;
		}
		if(n == 1){
			break;
		}
	}

	cout << n;
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	if(n == 1){
			cout << n;
			return 0;
	}
	int array[n];
    for(int i = 0; i < n; ++i){
		cin >> array[i];
	}

	bool isSorted = false;

	while(!isSorted){
		for(int i = 1; i < n; ++i){
			if(array[i-1]<=array[i]){
				isSorted = true;
			}
			else{
				isSorted = false;
				break;
			}
		}

		if(!isSorted){
			n /= 2;
		}
		if(n == 1){
			break;
		}
	}

	cout << n;
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	int array[n];
    for(int i = 0; i < n; ++i){
		cin >> array[i];
	}

	bool isSorted = false;

	while(!isSorted){
		for(int i = 1; i < n; ++i){
			if(array[i-1]<=array[i]){
				isSorted = true;
			}
			else{
				isSorted = false;
				break;
			}
		}

		if(!isSorted){
			n /= 2;
		}
		if(n == 1){
			break;
		}
	}

	cout << n;
	return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	int array[n];
    for(int i = 0; i < n; ++i){
		cin >> array[i];
	}
	for(int i = n; i > 0; i>>=1){
		for(int j = 0; j < n; j+=i){
			if(is_sorted(array+j,array+i+j)){
				cout << i;
				return 0;
			}
		}
	}
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;

int main(){
	int n;
	cin >> n;
	if(n == 1){
			return n;
	}
	int array[n];
    for(int i = 0; i < n; ++i){
		cin >> array[i];
	}

	bool isSorted = false;

	while(!isSorted){
		for(int i = 1; i < n; ++i){
			if(array[i-1]<=array[i]){
				isSorted = true;
			}
			else{
				isSorted = false;
				break;
			}
		}

		if(!isSorted){
			n /= 2;
		}
		if(n == 1){
			break;
		}
	}

	cout << n;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int pows[] = {1,2,4,8,16};
    int n;
    cin >> n;
    int arr[n];
    vector<bool*> ordered;
    ordered.push_back(new bool[n]);
    bool ord = true;
    for(int i = 0; i < n; i++){
		cin >> arr[i];
		ordered.back()[i] = true;
		ord = ord && (arr[i] >= arr[i-1]);
    }

    int maxOrdered = 1;
    if(!ord){
	    int levelOrdered = 1;
	    bool * back;
	    for(int i = n / 2; i >= 1; i /= 2){
	    	back = ordered.back();
			ordered.push_back(new bool[i]);
			for(int j = 0; j < i; j++){
			    int pos1 = j*pows[levelOrdered] + pows[levelOrdered-1];
			    int pos2 = j*pows[levelOrdered] + pows[levelOrdered -1] -1;
			    int aa1 = arr[pos1];
			    int aa2 = arr[pos2];
			    bool ordd = back[j*2] && back[j*2+1] && (aa1 >= aa2);
				ordered.back()[j] = ordd;
				if(ordd){
					maxOrdered = levelOrdered + 1;
				}
			}
			if(maxOrdered == levelOrdered){
				break;
			}else{
				levelOrdered++;
			}
		}
	}else{
		maxOrdered = n;
	}
	cout << maxOrdered;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int pows[] = {1,2,4,8,16};
    int n;
    cin >> n;
    int arr[n];
    vector<bool*> ordered;
    ordered.push_back(new bool[n]);
    bool ord = true;
	cin >> arr[0];
	ordered.back()[0] = true;
    for(int i = 1; i < n; i++){
		cin >> arr[i];
		ordered.back()[i] = true;
		ord = ord && (arr[i] >= arr[i-1]);
    }

    int maxOrdered = 1;
    if(!ord){
	    int levelOrdered = 1;
	    bool * back;
	    for(int i = n / 2; i >= 1; i /= 2){
	    	back = ordered.back();
			ordered.push_back(new bool[i]);
			for(int j = 0; j < i; j++){
				ordered.back()[j] = back[j*2] && back[j*2+1] && ((arr[j*pows[levelOrdered] + pows[levelOrdered-1]]) >= (arr[j*pows[levelOrdered] + pows[levelOrdered -1] -1]));
				if(ordered.back()[j]){
					maxOrdered = levelOrdered + 1;
				}
			}
			if(maxOrdered == levelOrdered){
				break;
			}else{
				levelOrdered++;
			}
		}
	}else{
		maxOrdered = n;
	}
	cout << maxOrdered;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int pows[] = {1,2,4,8,16};
    int n;
    cin >> n;
    int arr[n];
    vector<bool*> ordered;
    ordered.push_back(new bool[n]);
    bool ord = true;
    for(int i = 0; i < n; i++){
		cin >> arr[i];
		ordered.back()[i] = true;
    }

    int maxOrdered = 1;
	    int levelOrdered = 1;
	    bool * back;
	    for(int i = n / 2; i >= 1; i /= 2){
	    	back = ordered.back();
			ordered.push_back(new bool[i]);
			for(int j = 0; j < i; j++){
				ordered.back()[j] = back[j*2] && back[j*2+1] && ((arr[j*pows[levelOrdered] + pows[levelOrdered-1]]) >= (arr[j*pows[levelOrdered] + pows[levelOrdered -1] -1]));
				if(ordered.back()[j]){
					maxOrdered = levelOrdered + 1;
				}
			}
			if(maxOrdered == levelOrdered){
				break;
			}else{
				levelOrdered++;
			}
		}
	cout << maxOrdered;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int pows[] = {1,2,4,8,16};
    int n;
    cin >> n;
    int arr[n];
    vector<bool*> ordered;
    ordered.push_back(new bool[n]);
    bool ord = true;
    for(int i = 0; i < n; i++){
		cin >> arr[i];
		ordered.back()[i] = true;
		ord = ord && (arr[i] >= arr[i-1]);
    }

    int maxOrdered = 1;
    if(!ord){
	    int levelOrdered = 1;
	    bool * back;
	    for(int i = n / 2; i >= 1; i /= 2){
	    	back = ordered.back();
			ordered.push_back(new bool[i]);
			for(int j = 0; j < i; j++){
				ordered.back()[j] = back[j*2] && back[j*2+1] && ((arr[j*pows[levelOrdered] + pows[levelOrdered-1]]) >= (arr[j*pows[levelOrdered] + pows[levelOrdered -1] -1]));
				if(ordered.back()[j]){
					maxOrdered = levelOrdered + 1;
				}
			}
			if(maxOrdered == levelOrdered){
				break;
			}else{
				levelOrdered++;
			}
		}
	}else{
		maxOrdered = n;
	}
	cout << maxOrdered;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int pows[] = {1,2,4,8,16};
    int n;
    cin >> n;
    int arr[n];
    vector<bool*> ordered;
    ordered.push_back(new bool[n]);
    bool ord = true;
	cin >> arr[0];
	ordered.back()[0] = true;
    for(int i = 1; i < n; i++){
		cin >> arr[i];
		ordered.back()[i] = true;
    }

    int maxOrdered = 1;
	int levelOrdered = 1;
	bool * back;
	for(int i = n / 2; i >= 1; i /= 2){
	    back = ordered.back();
		ordered.push_back(new bool[i]);
		for(int j = 0; j < i; j++){
			ordered.back()[j] = back[j*2] && back[j*2+1] && ((arr[j*pows[levelOrdered] + pows[levelOrdered-1]]) >= (arr[j*pows[levelOrdered] + pows[levelOrdered -1] -1]));
			if(ordered.back()[j]){
				maxOrdered = levelOrdered + 1;
			}
		}
		if(maxOrdered == levelOrdered){
			break;
		}else{
			levelOrdered++;
		}
	}
	cout << pows[maxOrdered-1];
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int pows[] = {1,2,4,8,16};
    int n;
    cin >> n;
    int arr[n];
    vector<bool*> ordered;
    ordered.push_back(new bool[n]);
    bool ord = true;
	cin >> arr[0];
	ordered.back()[0] = true;
    for(int i = 1; i < n; i++){
		cin >> arr[i];
		ordered.back()[i] = true;
		ord = ord && (arr[i] >= arr[i-1]);
    }

    int maxOrdered = 1;
    if(!ord){
	    int levelOrdered = 1;
	    bool * back;
	    for(int i = n / 2; i >= 1; i /= 2){
	    	back = ordered.back();
			ordered.push_back(new bool[i]);
			for(int j = 0; j < i; j++){
				ordered.back()[j] = back[j*2] && back[j*2+1] && ((arr[j*pows[levelOrdered] + pows[levelOrdered-1]]) >= (arr[j*pows[levelOrdered] + pows[levelOrdered -1] -1]));
				if(ordered.back()[j]){
					maxOrdered = levelOrdered + 1;
				}
			}
			if(maxOrdered == levelOrdered){
				break;
			}else{
				levelOrdered++;
			}
		}
	}else{
		cout<< n;
		return 0;
	}
	cout << pows[maxOrdered-1];
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int find(int l,int r,int a[]){
    if(r-l==1){
        return (a[r]>=a[l]) ? 2:1;
    }
    int m=(r+l+1)/2,i;
    int rlen,llen,flag=0;
    llen=find(l,m-1,a);
    rlen=find(m,r,a);
    for(i=l;i<r;++i){
        if(a[i]>a[i+1]){
        flag=1;
        }
    }
    if(flag){
        return (llen>rlen)?llen:rlen;
    }
    return (r-l+1);
}
int main(){
    int n,i;
    scanf("%d",&n);
    int *a=(int*)malloc(n*sizeof(int));
    for(i=0;i<n;++i){
        scanf("%d",&a[i]);
    }
    int max;
    max=find(0,n-1,a);
    printf("%d",max);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*int find(int l,int r,int a[]){
    if(r-l==1){
        return (a[r]>=a[l]) ? 2:1;
    }
    int m=(r+l+1)/2,i;
    int rlen,llen,flag=0;
    llen=find(l,m-1,a);
    rlen=find(m,r,a);
    for(i=l;i<r;++i){
        if(a[i]>a[i+1]){
        flag=1;
        }
    }
    if(flag){
        return (llen>rlen)?llen:rlen;
    }
    return (r-l+1);
}*/
int main() {
    long long int n,i,j;
    scanf("%I64d",&n);
    int *a=(int*)malloc(n*sizeof(int));
    for(i=0; i<n; ++i) {
        scanf("%d",&a[i]);
    }
    int max,tp=1,flag=0;
    while(1) {
        for(i=1; i<=tp; ++i) {
            for(j=n*(i-1)+1; j<n*i; ++j) {
                if(a[j]<a[j-1]) {
                    break;
                }
            }
            if(j==n) {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
        n/=2;
        tp*=2;
    }
    printf("%I64d",n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[16];
int find(int l,int r){
    if(r-l==1){
        return (a[r]>=a[l]) ? 2:1;
    }
    int m=(r+l+1)/2,i;
    int rlen,llen,flag=0;
    llen=find(l,m-1);
    rlen=find(m,r);
    for(i=l;i<r;++i){
        if(a[i]>a[i+1]){
        flag=1;
        }
    }
    if(flag){
        return (llen>rlen)?llen:rlen;
    }
    return (r-l+1);
}
int main(){
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%d",&a[i]);
    }
    int max;
    max=find(0,n-1);
    printf("%d",max);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*int find(int l,int r,int a[]){
    if(r-l==1){
        return (a[r]>=a[l]) ? 2:1;
    }
    int m=(r+l+1)/2,i;
    int rlen,llen,flag=0;
    llen=find(l,m-1,a);
    rlen=find(m,r,a);
    for(i=l;i<r;++i){
        if(a[i]>a[i+1]){
        flag=1;
        }
    }
    if(flag){
        return (llen>rlen)?llen:rlen;
    }
    return (r-l+1);
}*/
int main() {
    int n,i,j;
    scanf("%d",&n);
    int *a=(int*)malloc(n*sizeof(int));
    for(i=0; i<n; ++i) {
        scanf("%d",&a[i]);
    }
    int max,tp=1,flag=0;
    while(1) {
        for(i=1; i<=tp; ++i) {
            for(j=n*(i-1)+1; j<n*i; ++j) {
                if(a[j]<a[j-1]) {
                    break;
                }
            }
            if(j==n) {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
        n/=2;
        tp*=2;
    }
    printf("%d",n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*int find(int l,int r,int a[]){
    if(r-l==1){
        return (a[r]>=a[l]) ? 2:1;
    }
    int m=(r+l+1)/2,i;
    int rlen,llen,flag=0;
    llen=find(l,m-1,a);
    rlen=find(m,r,a);
    for(i=l;i<r;++i){
        if(a[i]>a[i+1]){
        flag=1;
        }
    }
    if(flag){
        return (llen>rlen)?llen:rlen;
    }
    return (r-l+1);
}*/
int main() {
    long long int n,i,j;
    scanf("%I64d",&n);
    long long int *a=(long long int*)malloc(n*sizeof(long long int));
    for(i=0; i<n; ++i) {
        scanf("%I64d",&a[i]);
    }
    int max,tp=1,flag=0;
    while(1) {
        for(i=1; i<=tp; ++i) {
            for(j=n*(i-1)+1; j<n*i; ++j) {
                if(a[j]<a[j-1]) {
                    break;
                }
            }
            if(j==n) {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
        n/=2;
        tp*=2;
    }
    printf("%I64d",n);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*int find(int l,int r,int a[]){
    if(r-l==1){
        return (a[r]>=a[l]) ? 2:1;
    }
    int m=(r+l+1)/2,i;
    int rlen,llen,flag=0;
    llen=find(l,m-1,a);
    rlen=find(m,r,a);
    for(i=l;i<r;++i){
        if(a[i]>a[i+1]){
        flag=1;
        }
    }
    if(flag){
        return (llen>rlen)?llen:rlen;
    }
    return (r-l+1);
}*/
int main() {
    long long int n,i,j;
    scanf("%I64d",&n);
    long long int *a=(long long int*)malloc(n*sizeof(long long int));
    for(i=0; i<n; ++i) {
        scanf("%I64d",&a[i]);
    }
    int max,tp=1,flag=0;
    while(1) {
        for(i=1; i<=tp; ++i) {
            for(j=n*(i-1)+1; j<n*i; ++j) {
                if(a[j]<a[j-1]) {
                    break;
                }
            }
            if(j==n*i) {
                flag=1;
                break;
            }
        }
        if(flag)
            break;
        n/=2;
        tp*=2;
    }
    printf("%I64d",n);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
   int n,a[1024];
   scanf("%d",&n);
   for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
   }
   for(int i=n;i>=1;i>>=1){
        for(int j=0;j<n;j+=i){
            bool res=1;
            for(int k=j+1;k<j+i;k++){
                res&=(a[k]>=a[k-1]);
            }
            if(res){printf("%d\n",i);return 0;}
        }
   }

}


#include <bits/stdc++.h>
using namespace std;

int main(){
   int n,a[1024];
   scanf("%d",&n);
   for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
   }
   for(int i=n;i>=1;i>>=2){
        for(int j=0;j<n;j+=i){
            bool res=1;
            for(int k=j+1;k<j+i;k++){
                res&=(a[k]>=a[k-1]);
            }
            if(res){printf("%d\n",i);return 0;}
        }
   }

}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 10000000;
const double pi = 3.14159265358979;

double x[N], y[N];
double R, r;
int n;

double dis(int i){

	return sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));

}

void seg_dis(int i){
	int j = i+1;
	double d = dis(i);
	R = max(R, d);
	r = min(r, d);
	if(i == n) j = 1;
	double x1 = x[0]-x[i], x2 = x[j]-x[i], y1 = y[0]-y[i], y2 = y[j]-y[i];
	double iner = x1*x2+y1*y2;
	if(iner < 0) return;
	if(iner > x2*x2+y2*y2) return;
	d = abs(x1*y2-x2*y1);
	d/= sqrt(x2*x2+y2*y2);
	r = min(d, r);
}

int main () {

	cin >> n;

	cin >> x[0] >> y[0];

	for(int i = 1; i <= n; i++) {

	cin >> x[i] >> y[i];

	}

	R = -1, r = 10000000000;

	for(int i = 1; i <= n; i++){

		seg_dis(i);
	}

	cout << fixed << setprecision(20) << (R*R-r*r)*pi;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 10000000;
const double pi = 3.14159265358979;

double x[N], y[N];
double R, r;
int n;

double dis(int i){

	return sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));

}

void seg_dis(int i){

	int j = i+1;

	double d = dis(i);

	R = max(R, d);

	r = min(r, d);

	if(i == n){
	    j = 1;
	}

	double x1 = x[0]-x[i], x2 = x[j]-x[i], y1 = y[0]-y[i], y2 = y[j]-y[i];

	double iner = x1*x2+y1*y2;

	if(iner < 0){return 0;}

	if(iner > x2*x2+y2*y2){return 0;}

	d = abs(x1*y2-x2*y1);

	d/= sqrt(x2*x2+y2*y2);

	r = min(d, r);
}

int main () {

	cin >> n;

	cin >> x[0] >> y[0];

	for(int i = 1; i <= n; i++) {

	cin >> x[i] >> y[i];

	}

	R = -1, r = 10000000000;

	for(int i = 1; i <= n; i++){

		seg_dis(i);
	}

	cout << fixed << setprecision(20) << (R*R-r*r)*pi;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 10000000;
const double pi = 3.14159265358979;

double x[N], y[N];
double R, r;
int n;

double dis(int i){

	return sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));

}

void seg_dis(int i){

	int j = i+1;

	double d = dis(i);

	R = max(R, d);

	r = min(r, d);

	if(i == n){
	    j = 1;
	}

	double x1 = x[0]-x[i], x2 = x[j]-x[i], y1 = y[0]-y[i], y2 = y[j]-y[i];

	double iner = x1*x2+y1*y2;

	if(iner < 0){}

	if(iner > x2*x2+y2*y2){}

	d = abs(x1*y2-x2*y1);

	d/= sqrt(x2*x2+y2*y2);

	r = min(d, r);
}

int main () {

	cin >> n;

	cin >> x[0] >> y[0];

	for(int i = 1; i <= n; i++) {

	cin >> x[i] >> y[i];

	}

	R = -1, r = 10000000000;

	for(int i = 1; i <= n; i++){

		seg_dis(i);
	}

	cout << fixed << setprecision(20) << (R*R-r*r)*pi;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 10000000;
const double pi = 3.14159265358979;

double x[N], y[N];
double R, r;
int n;

double dis(int i){

	return sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));

}

void seg_dis(int i){

	int j = i+1;

	double d = dis(i);

	R = max(R, d);

	r = min(r, d);

	if(i == n){
	    j = 1;
	}

	double x1 = x[0]-x[i], x2 = x[j]-x[i], y1 = y[0]-y[i], y2 = y[j]-y[i];

	double iner = x1*x2+y1*y2;

	if(iner < 0){break;}

	if(iner > x2*x2+y2*y2){break;}

	d = abs(x1*y2-x2*y1);

	d/= sqrt(x2*x2+y2*y2);

	r = min(d, r);
}

int main () {

	cin >> n;

	cin >> x[0] >> y[0];

	for(int i = 1; i <= n; i++) {

	cin >> x[i] >> y[i];

	}

	R = -1, r = 10000000000;

	for(int i = 1; i <= n; i++){

		seg_dis(i);
	}

	cout << fixed << setprecision(20) << (R*R-r*r)*pi;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 10000000;
const double pi = 3.14159265358979;

double x[N], y[N];
double R, r;
int n;

double dis(int i){

	return sqrt((x[i]-x[0])*(x[i]-x[0])+(y

[i]-y[0])*(y[i]-y[0]));

}

void distance(int i){
    //a
	int j = i+1;

	double d = dis(i);

	R = max(R, d);

	r = min(r, d);

	if(i == n){
	    j = 1;
	}

	double x1 = x[0]-x[i], x2 = x[j]-x[i],

    double y1 = y[0]-y[i], y2 = y[j]-y[i];

	double iner = x1*x2+y1*y2;

	if(iner < 0) return 0;

	if(iner > x2*x2+y2*y2) return 0;

	d = abs(x1*y2-x2*y1);

	d/= sqrt(x2*x2+y2*y2);

	r = min(d, r);
}

int main () {

	cin >> n;

	cin >> x[0] >> y[0];

	for(int i = 1; i <= n; i++) {

	cin >> x[i] >> y[i];

	}

	R = -1, r = 10000000000;

	for(int i = 1; i <= n; i++){

		distance(i);
	}

	cout << fixed << setprecision(20) << (R*R-r*r)*pi;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 10000000;
const double pi = 3.14159265358979;

double x[N], y[N];
double R, r;
int n;

double dis(int i){

	return sqrt((x[i]-x[0])*(x[i]-x[0])+(y

[i]-y[0])*(y[i]-y[0]));

}

void distance(int i){

	int j = i+1;

	double d = dis(i);

	R = max(R, d);

	r = min(r, d);

	if(i == n){
	    j = 1;
	}

	double x1 = x[0]-x[i], x2 = x[j]-x[i],

    double y1 = y[0]-y[i], y2 = y[j]-y[i];

	double iner = x1*x2+y1*y2;

	if(iner < 0) return 0;

	if(iner > x2*x2+y2*y2) return 0;

	d = abs(x1*y2-x2*y1);

	d/= sqrt(x2*x2+y2*y2);

	r = min(d, r);
}

int main () {

	cin >> n;

	cin >> x[0] >> y[0];

	for(int i = 1; i <= n; i++) {

	cin >> x[i] >> y[i];

	}

	R = -1, r = 10000000000;

	for(int i = 1; i <= n; i++){

		distance(i);
	}

	cout << fixed << setprecision(20) << (R*R-r*r)*pi;
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

const int N = 10000000;
const double pi = 3.14159265358979;

double x[N], y[N];
double R, r;
int n;

double dis(int i){

	return sqrt((x[i]-x[0])*(x[i]-x[0])+(y[i]-y[0])*(y[i]-y[0]));

}

void seg_dis(int i){

	int j = i+1;

	double d = dis(i);

	R = max(R, d);

	r = min(r, d);

	if(i == n){
	    j = 1;
	}

	double x1 = x[0]-x[i], x2 = x[j]-x[i], y1 = y[0]-y[i], y2 = y[j]-y[i];

	double iner = x1*x2+y1*y2;

	d = abs(x1*y2-x2*y1);

	d/= sqrt(x2*x2+y2*y2);

	r = min(d, r);
}

int main () {

	cin >> n;

	cin >> x[0] >> y[0];

	for(int i = 1; i <= n; i++) {

	cin >> x[i] >> y[i];

	}

	R = -1, r = 10000000000;

	for(int i = 1; i <= n; i++){

		seg_dis(i);
	}

	cout << fixed << setprecision(20) << (R*R-r*r)*pi;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>

using namespace std;

#define PI 3.1415926535897932384626433832795028841971693993751058209749

struct Point {
	int x;
	int y;
	Point(int a, int b) {
		x = a, y = b;
	}
};

int orientation(Point p1, Point p2, Point p3)
{
	// See 10th slides from following link for derivation
	// of the formula
	int val = (p2.y - p1.y) * (p3.x - p2.x) -
		(p2.x - p1.x) * (p3.y - p2.y);

	if (val == 0) return 0;  // colinear

	return (val > 0) ? 1 : 2; // clock or counterclock wise
}

int main() {
	int n, x, y;
	double mind = 1000 * 1000 * 1000;
	double maxd = -1;
	vector<pair<int, int>> points;
	cin >> n >> x >> y;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		points.push_back(make_pair(a, b));
	}
	for (int i = 0; i < n; i++) {
		pair<int, int> A = points[i];
		pair<int, int> B;
		if (i == n - 1)B = points[0];
		else B = points[i + 1];
		pair<int, int> AB = make_pair(B.first - A.first, B.second - A.second);
		int a = AB.first; int b = AB.second;
		int xa = A.first; int ya = A.second;
		int xb = B.first; int yb = B.second;
		double fc = a * (xa - x+0.0) + b * (ya - y+0.0);
		double sc = a * (xb - x+0.0) + b * (yb - y+0.0);
		double wgi = (x+0.0 - xa)*(x - xa) + (y+0.0 - ya)*(y - ya);
		double d = sqrt(wgi);
		mind = min(mind, d);
		maxd = max(maxd, d);
		wgi = (x+0.0 - xb)*(x - xb) + (y+0.0 - yb)*(y - yb);
		d = sqrt(wgi);
		mind = min(mind, d);
		maxd = max(maxd, d);
		if (fc != 0 && sc != 0) {
			int xp = x + (-b); int yp = y + a;
			int o1 = orientation(Point(x, y), Point(xp, yp), Point(xa, ya));
			int o2 = orientation(Point(x, y), Point(xp, yp), Point(xb, yb));
			if (o1 != o2) {
				double xi = a * a*(x+0.0) + a * b*(y - ya+0.0) + b * b*(xa+0.0);
				xi = xi / (a*a + b * b);
				double yi = a * a*(ya+0.0) + a * b*(x - xa+0.0) + b * b*(y+0.0);
				yi = yi / (a*a + b * b);
				d = sqrt((x - xi)*(x - xi) + (y - yi)*(y - yi) + 0.0);
				mind = min(mind, d);
			}
		}
	}
	double ans = PI * (maxd*maxd - mind * mind);
	cout << fixed << setprecision(20) << ans << endl;
	return 0;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>

using namespace std;

#define PI 3.1415926535897932384626433832795028841971693993751058209749

int main() {
	int n, x, y;
	double mind = 1000 * 1000 * 1000;
	double maxd = -1;
	vector<pair<int, int>> points;
	cin >> n >> x >> y;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		points.push_back(make_pair(a, b));
	}
	for (int i = 0; i < n; i++) {
		pair<int, int> A = points[i];
		pair<int, int> B;
		if (i == n - 1)B = points[0];
		else B = points[i + 1];
		pair<int, int> AB = make_pair(B.first - A.first, B.second - A.second);
		int a = AB.first; int b = AB.second;
		int xa = A.first; int ya = A.second;
		int xb = B.first; int yb = B.second;
		// check if A or B is the projection of C on AB
		int fc = a*(xa - x) + b*(ya - y);
		int sc = a*(xb - x) + b*(yb - y);
		double d = sqrt((x - xa)*(x - xa) + (y - ya)*(y - ya) + 0.0);
		mind = min(mind, d);
		maxd = max(maxd, d);
		d = sqrt((x - xb)*(x - xb) + (y - yb)*(y - yb) + 0.0);
		mind = min(mind, d);
		maxd = max(maxd, d);
		if (fc != 0 && sc != 0) {
			// find intersection point
			double xi = a * a*x + a * b*(y - ya) + b * b*xa;
			xi = xi / (a*a + b * b);
			double yi = a * a*ya + a * b*(x - xa) + b * b*y;
			yi = yi / (a*a + b * b);
			// need to check if H belong to [AB]
			// dot product IA.IB (if -ve then it does , if =ve it does not)
			double s = (xa - xi)*(xb - xi) + (ya - yi)*(yb - yi);
			if (s < 0) {
				d = sqrt((x - xi)*(x - xi) + (y - yi)*(y - yi) + 0.0);
				mind = min(mind, d);
			}
		}
	}
	double ans = PI * (maxd*maxd - mind * mind);
	cout << fixed << setprecision(20) << ans << endl;
	//system("pause");
	return 0;
}


#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>

using namespace std;

#define PI 3.1415926535897932384626433832795028841971693993751058209749

struct Point {
	int x;
	int y;
	Point(int a, int b) {
		x = a, y = b;
	}
};

int orientation(Point p1, Point p2, Point p3)
{
	// See 10th slides from following link for derivation
	// of the formula
	int val = (p2.y - p1.y) * (p3.x - p2.x) -
		(p2.x - p1.x) * (p3.y - p2.y);

	if (val == 0) return 0;  // colinear

	return (val > 0) ? 1 : 2; // clock or counterclock wise
}

int main() {
	int n, x, y;
	double mind = 1000 * 1000 * 1000;
	double maxd = -1;
	vector<pair<int, int>> points;
	cin >> n >> x >> y;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		points.push_back(make_pair(a, b));
	}
	for (int i = 0; i < n; i++) {
		pair<int, int> A = points[i];
		pair<int, int> B;
		if (i == n - 1)B = points[0];
		else B = points[i + 1];
		pair<int, int> AB = make_pair(B.first - A.first, B.second - A.second);
		int a = AB.first; int b = AB.second;
		int xa = A.first; int ya = A.second;
		int xb = B.first; int yb = B.second;
		int fc = a * (xa - x) + b * (ya - y);
		int sc = a * (xb - x) + b * (yb - y);
		double d = sqrt((x - xa)*(x - xa) + (y - ya)*(y - ya) + 0.0);
		mind = min(mind, d);
		maxd = max(maxd, d);
		d = sqrt((x - xb)*(x - xb) + (y - yb)*(y - yb) + 0.0);
		mind = min(mind, d);
		maxd = max(maxd, d);
		if (fc != 0 && sc != 0) {
			int xp = x + (-b); int yp = y + a;
			int o1 = orientation(Point(x, y), Point(xp, yp), Point(xa, ya));
			int o2 = orientation(Point(x, y), Point(xp, yp), Point(xb, yb));
			if (o1 != o2) {
				double xi = a * a*x + a * b*(y - ya) + b * b*xa;
				xi = xi / (a*a + b * b);
				double yi = a * a*ya + a * b*(x - xa) + b * b*y;
				yi = yi / (a*a + b * b);
				d = sqrt((x - xi)*(x - xi) + (y - yi)*(y - yi) + 0.0);
				mind = min(mind, d);
			}
		}
	}
	double ans = PI * (maxd*maxd - mind * mind);
	cout << fixed << setprecision(20) << ans << endl;
	return 0;
}