#include <bits/stdc++.h>
using namespace std;
int arr, cpy[100200];
int main() {
  int n, one = 0, two = 0, mx, x = 0, i;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr);
    if (arr == 1) {
      if (two != 0) cpy[x++] = two;
      one++;
      two = 0;
    } else if (arr == 2) {
      if (one != 0) cpy[x++] = one;
      two++;
      one = 0;
    }
  }
  if (arr == 1)
    cpy[x++] = one;
  else if (arr == 2)
    cpy[x++] = two;
  int value;
  mx = 0;
  for (i = 1; i < x; i++) {
    if (cpy[i] < cpy[i - 1]) {
      value = cpy[i] * 2;
      if (mx < value) mx = value;
    } else if (cpy[i] >= cpy[i - 1]) {
      value = cpy[i - 1] * 2;
      if (mx < value) mx = value;
    }
  }
  printf("%d\n", mx);
  return 0;
}
