#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, as = 1, ma = -1, cn = 1;
  cin >> n;
  int s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i + 1 < n; i++) {
    if (s[i] == s[i + 1]) {
      cn++;
    } else {
      as = cn;
      cn = 1;
    }
    ma = max(ma, min(as, cn));
  }
  cout << 2 * ma;
}
