#include <bits/stdc++.h>
using namespace std;
const long long N = 50005;
const int mod = 1e9 + 7;
const long long INF = 1e18;
void solve() {
  long long n;
  cin >> n;
  vector<long long> v;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    long long cnt = 0;
    if (a[i] == 1) {
      while (a[i] == 1 and i < n) {
        cnt++;
        i++;
      }
      i--;
    } else {
      while (a[i] == 2 and i < n) {
        cnt++;
        i++;
      }
      i--;
    }
    v.push_back(cnt);
  }
  long long mx = -INF;
  n = ((int)(v).size());
  for (long long i = 0; i < n - 1; i++) {
    mx = max(mx, 2 * min(v[i], v[i + 1]));
  }
  cout << mx;
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
