Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

The problem statement has recently been changed. View the changes.

×
A. Thanos Sort

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputThanos sort is a supervillain sorting algorithm, which works as follows: if the array is not sorted, snap your fingers* to remove the first or the second half of the items, and repeat the process.

Given an input array, what is the size of the longest sorted array you can obtain from it using Thanos sort?

*Infinity Gauntlet required.

Input

The first line of input contains a single number $$$n$$$ ($$$1 \le n \le 16$$$) — the size of the array. $$$n$$$ is guaranteed to be a power of 2.

The second line of input contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \le a_i \le 100$$$) — the elements of the array.

Output

Return the maximal length of a sorted array you can obtain using Thanos sort. The elements of the array have to be sorted in non-decreasing order.

Examples

Input

4 1 2 2 4

Output

4

Input

8 11 12 1 2 13 14 3 4

Output

2

Input

4 7 6 5 4

Output

1

Note

In the first example the array is already sorted, so no finger snaps are required.

In the second example the array actually has a subarray of 4 sorted elements, but you can not remove elements from different sides of the array in one finger snap. Each time you have to remove either the whole first half or the whole second half, so you'll have to snap your fingers twice to get to a 2-element sorted array.

In the third example the array is sorted in decreasing order, so you can only save one element from the ultimate destruction.

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/16/2021 09:58:41 (h3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|