#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  };
  int n;
  cin >> n;
  int x;
  int c2 = 0, c1 = 0;
  int flag = 0;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 2) {
      if (c1) v.push_back(c1);
      c1 = 0;
      c2++;
    } else {
      if (c2) v.push_back(c2);
      c2 = 0;
      c1++;
    }
  }
  if (c2)
    v.push_back(c2);
  else if (c1)
    v.push_back(c1);
  int maxm = 0;
  for (int i = 1; i < v.size(); i++) {
    if (v[i] <= v[i - 1]) {
      maxm = max(maxm, v[i] * 2);
    } else
      maxm = max(maxm, v[i - 1] * 2);
  }
  cout << maxm << endl;
  return 0;
}
