#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, t = 0, e = 0, smax = 0, a[100002];
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    if (a[i] == 1) {
      if (a[i - 1] == 2) {
        smax = max(smax, min(e, t));
        t = 0;
      }
      t++;
    } else if (a[i] == 2) {
      if (a[i - 1] == 1) {
        smax = max(smax, min(e, t));
        e = 0;
      }
      e++;
    }
  }
  smax = max(smax, min(t, e)) * 2;
  cout << smax << endl;
  return 0;
}
