#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n = 0;
  cin >> n;
  vector<int> a(n, 0);
  for (int i = 0, x = 0; i < n; ++i) {
    cin >> x;
    a[i] = x;
  }
  int ans = 0, mxT = 0, mxU = 0;
  if (a[0] == 1) {
    ++mxT;
  } else {
    ++mxU;
  }
  for (int i = 1; i < n; ++i) {
    if (a[i - 1] == a[i]) {
      if (a[i] == 1) {
        ++mxT;
      } else if (a[i] == 2) {
        ++mxU;
      }
      ans = max(ans, min(mxT, mxU));
    } else {
      if (a[i] == 1) {
        mxT = 1;
      } else if (a[i] == 2) {
        mxU = 1;
      }
      ans = max(ans, min(mxT, mxU));
    }
  }
  cout << 2 * ans;
  return 0;
}
