CodeForces - 1138A
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n+5];
for(int i=0;i<n;i++) arr[i] = sc.nextInt();
int res = 0;
int l = 1;
for(int i=0;i<n;i++){
int r = 1;
int j = i+1;
while(j<n&&arr[j]==arr[i]){
r ++;
j ++;
}
res = Math.max(res,Math.min(l,r));
l = r;
i = j-1;
}
System.out.print(res*2);
}
}