#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int a[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int flag = 0, sum1 = 1, sum2 = 1, ans = 0;
  for (int i = 2; i <= n; i++) {
    if (a[i] == a[i - 1]) {
      if (a[i] == 2) {
        sum2++;
      }
      if (a[i] == 1) {
        sum1++;
      }
    }
    if (a[i] != a[i - 1]) {
      if (a[i] == 2) {
        ans = max(ans, min(sum1, sum2));
        sum2 = 1;
      }
      if (a[i] == 1) {
        ans = max(ans, min(sum1, sum2));
        sum1 = 1;
      }
    }
  }
  ans = max(ans, min(sum1, sum2));
  printf("%d", ans * 2);
}
