#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, len, i, count, maxc = 0;
  cin >> n;
  vector<int> a(n), b(n);
  for (i = 0; i < n; i++) cin >> a[i];
  i = 0;
  len = 0;
  while (i < n) {
    count = 0;
    if (a[i] == 1) {
      while ((i < n) && (a[i] == 1)) {
        count++;
        i++;
      }
      b[len++] = count;
    } else {
      while ((i < n) && (a[i] == 2)) {
        count++;
        i++;
      }
      b[len++] = count;
    }
  }
  for (i = 0; i < len - 1; i++) {
    maxc = max(maxc, min(b[i], b[i + 1]));
  }
  cout << (maxc * 2) << endl;
  return 0;
}
