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].
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.security.AccessControlException;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
public class _p001138A {
    static public void main(final String[] args) throws IOException {
        p001138A._main(args);
    }
//begin p001138A.java
static private class p001138A extends Solver{public p001138A(){nameIn="in/900/p001138A.in"
;singleTest=true;}int n;int[]t;@Override protected void solve(){int res=0;int prev
=0;int[]prev_count=new int[2];int prev_selector=0;for(int i=0;i<n;i++){if(t[i]!=
prev){if(prev>0){prev_selector^=1;if(res<2*Math.min(prev_count[0],prev_count[1])
){res=2*Math.min(prev_count[0],prev_count[1]);}prev_count[prev_selector]=0;}prev
=t[i];}prev_count[prev_selector]++;}if(res<2*Math.min(prev_count[0],prev_count[1
])){res=2*Math.min(prev_count[0],prev_count[1]);}pw.println(res);}@Override public
void readInput()throws IOException{n=sc.nextInt();if(sc.hasNextLine()){sc.nextLine
();}t=Arrays.stream(sc.nextLine().trim().split("\\s+")).mapToInt(Integer::valueOf
).toArray();}static public void _main(String[]args)throws IOException{new p001138A
().run();}}
//end p001138A.java
//begin net/leksi/contest/Solver.java
static private abstract class Solver{protected String nameIn=null;protected String
nameOut=null;protected boolean singleTest=false;protected boolean preprocessDebug
=false;protected boolean doNotPreprocess=false;protected PrintStream debugPrintStream
=null;protected Scanner sc=null;protected PrintWriter pw=null;final String SPACE
=" ";final String SPACES="\\s+";private void process()throws IOException{if(!singleTest
){int t=lineToIntArray()[0];while(t-->0){readInput();solve();}}else{readInput();
solve();}}abstract protected void readInput()throws IOException;abstract protected
void solve()throws IOException;protected int[]lineToIntArray()throws IOException
{return Arrays.stream(sc.nextLine().trim().split(SPACES)).mapToInt(Integer::valueOf
).toArray();}protected long[]lineToLongArray()throws IOException{return Arrays.stream
(sc.nextLine().trim().split(SPACES)).mapToLong(Long::valueOf).toArray();}protected
String joinToString(final int[]a){return Arrays.stream(a).mapToObj(Integer::toString
).collect(Collectors.joining(SPACE));}protected String joinToString(final long[]
a){return Arrays.stream(a).mapToObj(Long::toString).collect(Collectors.joining(SPACE
));}protected<T>String joinToString(final T[]a){return Arrays.stream(a).map(v->Objects
.toString(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString
(final T[]a,final Function<T,String>toString){return Arrays.stream(a).map(v->toString
.apply(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString(final
Collection<T>a){return a.stream().map(v->Objects.toString(v)).collect(Collectors
.joining(SPACE));}protected<T>String joinToString(final Collection<T>a,final Function<T
,String>toString){return a.stream().map(v->toString.apply(v)).collect(Collectors
.joining(SPACE));}protected<T>String joinToString(final Stream<T>a){return a.map
(v->Objects.toString(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString
(final Stream<T>a,final Function<T,String>toString){return a.map(v->toString.apply
(v)).collect(Collectors.joining(SPACE));}protected<T>String joinToString(final IntStream
a){return a.mapToObj(Integer::toString).collect(Collectors.joining(SPACE));}protected
<T>String joinToString(final LongStream a){return a.mapToObj(Long::toString).collect
(Collectors.joining(SPACE));}protected List<Long>intArrayToLongList(final int[]a
){return Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors.toList());}
protected List<Integer>toList(final int[]a){return Arrays.stream(a).mapToObj(Integer
::valueOf).collect(Collectors.toList());}protected List<Integer>toList(final IntStream
a){return a.mapToObj(Integer::valueOf).collect(Collectors.toList());}protected List<Long>
toList(final long[]a){return Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors
.toList());}protected List<Long>toList(final LongStream a){return a.mapToObj(Long
::valueOf).collect(Collectors.toList());}protected<T>List<T>toList(final Stream<T>
a){return a.collect(Collectors.toList());}protected<T>List<T>toList(final T[]a){
return Arrays.stream(a).collect(Collectors.toList());}protected void run()throws
IOException{boolean done=false;try{if(nameIn !=null&&new File(nameIn).exists()){
try(FileInputStream fis=new FileInputStream(nameIn);PrintWriter pw0=select_output
();){done=true;sc=new Scanner(fis);pw=pw0;process();}}}catch(IOException ex){}catch
(AccessControlException ex){}if(!done){try(PrintWriter pw0=select_output();){sc=
new Scanner(System.in);pw=pw0;process();}}}private PrintWriter select_output()throws
FileNotFoundException{if(nameOut !=null){return new PrintWriter(nameOut);}return
new PrintWriter(System.out);}}
//end net/leksi/contest/Solver.java
}
