#include <bits/stdc++.h>
using namespace std;
void kk() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
int main() {
  kk();
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int ones = 0, twos = 0;
  bool swtch = 0, swtch2 = 0;
  int ans = 0;
  if (arr[0] == 1)
    ones++, swtch = 1;
  else
    twos++, swtch2 = 1;
  for (int i = 1; i < n; i++) {
    if (arr[i] == 1) {
      if (!swtch) {
        ones = 1;
        swtch = 1;
        swtch2 = 0;
      } else
        ones++;
    } else {
      if (!swtch2) {
        twos = 1;
        swtch2 = 1;
        swtch = 0;
      } else
        twos++;
    }
    ans = max(ans, min(ones, twos));
  }
  cout << ans * 2;
  return 0;
}
