#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n;
  cin >> n;
  int sushi[200000];
  for (int i = 0; i < n; i++) {
    cin >> sushi[i];
  }
  int ContSushi[200000];
  ContSushi[0] = 1;
  int p = 0;
  for (int i = 1; i < n; i++) {
    if (sushi[i] == sushi[i - 1]) {
      ContSushi[p] = ContSushi[p] + 1;
    } else {
      p++;
      ContSushi[p]++;
    }
  }
  int sumam = 0;
  int sumat;
  for (int i = 1; i < (p + 1); i++) {
    sumat = min(ContSushi[i], ContSushi[i - 1]);
    if (sumat > sumam) {
      sumam = sumat;
    }
  }
  cout << (sumam)*2 << endl;
  return 0;
}
