#include <bits/stdc++.h>
using namespace std;
template <typename T>
string tos(T a) {
  stringstream ss;
  string ret;
  ss << a;
  ss >> ret;
  return ret;
}
void read(int &_a) { int temp = scanf("%d", &_a); }
void read(int &_a, int &_b) { int temp = scanf("%d %d", &_a, &_b); }
void read(int &_a, int &_b, int &_c) {
  int temp = scanf("%d %d %d", &_a, &_b, &_c);
}
vector<int> T;
int N;
int main() {
  while (cin >> N) {
    T.clear();
    int v, p = 0, cnt = 0;
    for (int(x) = (0); (x) < (N); (x)++) {
      read(v);
      if (v == p) {
        cnt++;
      } else {
        if (cnt) T.push_back(cnt);
        p = v;
        cnt = 1;
      }
    }
    if (cnt) T.push_back(cnt);
    int len = T.size();
    int ans = 0;
    for (int(x) = (1); (x) < (len); (x)++) {
      ans = max(ans, min(T[x - 1], T[x]) * 2);
    }
    cout << ans << endl;
  }
  return 0;
}
