Arkady invited Anna for a dinner to a sushi restaurant. The restaurant is a bit unusual: it offers n pieces of sushi aligned in a row, and a customer has to choose a continuous subsegment of these sushi to buy.

The pieces of sushi are of two types: either with tuna or with eel. Let's denote the type of the i-th from the left sushi as t_i, where t_i = 1 means it is with tuna, and t_i = 2 means it is with eel.

Arkady does not like tuna, Anna does not like eel. Arkady wants to choose such a continuous subsegment of sushi that it has equal number of sushi of each type and each half of the subsegment has only sushi of one type. For example, subsegment [2, 2, 2, 1, 1, 1] is valid, but subsegment [1, 2, 1, 2, 1, 2] is not, because both halves contain both types of sushi.

Find the length of the longest continuous subsegment of sushi Arkady can buy.

Input

The first line contains a single integer n (2 ≤ n ≤ 100 000) — the number of pieces of sushi.

The second line contains n integers t_1, t_2, ..., t_n (t_i = 1, denoting a sushi with tuna or t_i = 2, denoting a sushi with eel), representing the types of sushi from left to right.

It is guaranteed that there is at least one piece of sushi of each type. Note that it means that there is at least one valid continuous segment.

Output

Print a single integer — the maximum length of a valid continuous segment.

Examples

Input


7
2 2 2 1 1 2 2


Output


4


Input


6
1 2 1 2 1 2


Output


2


Input


9
2 2 1 1 1 2 2 2 2


Output


6

Note

In the first example Arkady can choose the subsegment [2, 2, 1, 1] or the subsegment [1, 1, 2, 2] with length 4.

In the second example there is no way but to choose one of the subsegments [2, 1] or [1, 2] with length 2.

In the third example Arkady's best choice is the subsegment [1, 1, 1, 2, 2, 2].
#Winners never quit, Quitters never win............................................................................
from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

def factors(n):    
    return set(reduce(list.__add__, 
                ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))
class My_stack():
    def __init__(self):
        self.data = []
    def my_push(self, x):
        return (self.data.append(x))
    def my_pop(self):
        return (self.data.pop())
    def my_peak(self):
        return (self.data[-1])
    def my_contains(self, x):
        return (self.data.count(x))
    def my_show_all(self):
        return (self.data)
    def isEmpty(self):
      return len(self.data)==0

arrStack = My_stack()    
def decimalToBinary(n): 
    return bin(n).replace("0b", "")

def isPrime(n) : 
	if (n <= 1) : 
		return False
	if (n <= 3) : 
		return True

	
	if (n % 2 == 0 or n % 3 == 0) : 
		return False

	i = 5
	while(i * i <= n) : 
		if (n % i == 0 or n % (i + 2) == 0) : 
			return False
		i = i + 6

	return True

def get_prime_factors(number):
    prime_factors = []
    while number % 2 == 0:
        prime_factors.append(2)
        number = number / 2
    for i in range(3, int(math.sqrt(number)) + 1, 2):
        while number % i == 0:
            prime_factors.append(int(i))
            number = number / i

    if number > 2:
        prime_factors.append(int(number))

    return prime_factors
def get_frequency(list):
    dic={}
    for ele in list:
        if ele in dic:
            dic[ele] += 1
        else:
            dic[ele] = 1
    return dic
def Log2(x): 
    return (math.log10(x) / 
            math.log10(2)); 

def isPowerOfTwo(n): 
    return (math.ceil(Log2(n)) == math.floor(Log2(n))); 
def ceildiv(x,y): return (x+y-1)//y #ceil  function gives wrong answer after 10^17 so i have to create my own :)
# because i don't want to doubt on my solution of 900-1000 problem set.  

#here we go......................
#Winners never quit, Quitters never win
n=int(input())
t=list(map(int,input().split()))
grouping=[]
curr=1
lastcheck=1
for i in range(1,n):
    if t[i] !=t[i-1]:
        grouping.append(curr)
        curr=1
        if i==n-1:
            lastchekcheck=0
    else:
        curr+=1
if lastcheck:
    grouping.append(curr)
#print(grouping)
maxlen=0
for i in range(1,len(grouping)):
    if min(grouping[i],grouping[i-1])*2 > maxlen:
        maxlen=2*(min(grouping[i],grouping[i-1]))
print(maxlen)

    
    
    

