#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a = 0, p = 0, n, x;
  vector<long long> V;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> x;
    if (x == p or p == 0)
      a++;
    else {
      V.push_back(a);
      a = 1;
    }
    p = x;
  }
  V.push_back(a);
  long long l = 0;
  for (long long i = 1; i < V.size(); i++) {
    l = max(min(V[i - 1], V[i]) * 2, l);
  }
  cout << l;
}
