#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n), fin;
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  for (long long int i = 0; i < n; i++) {
    long long int temp = 0;
    if (arr[i] == 1) {
      while (arr[i] == 1 && i < n) {
        temp++;
        i++;
      }
      i--;
      fin.push_back(temp);
      continue;
    }
    if (arr[i] == 2) {
      while (arr[i] == 2 && i < n) {
        temp++;
        i++;
      }
      i--;
      fin.push_back(temp);
      continue;
    }
  }
  long long int max = 0;
  for (long long int i = 0; i < fin.size() - 1; i++) {
    if (2 * min(fin[i], fin[i + 1]) > max) max = 2 * min(fin[i], fin[i + 1]);
  }
  cout << max;
  return 0;
}
