#include <bits/stdc++.h>
using namespace std;
int arr[1000001];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int dem1 = 0;
  int dem2 = 0;
  arr[0] == 1 ? dem1++ : dem2++;
  int sum = 2;
  for (int i = 1; i < n; i++) {
    if (arr[i] == arr[i - 1] && arr[i] == 1) {
      dem1++;
    } else if (arr[i] != arr[i - 1] && arr[i] == 2) {
      sum = max(sum, min(dem1, dem2) * 2);
      dem2 = 1;
    } else if (arr[i] == arr[i - 1] && arr[i] == 2) {
      dem2++;
    } else if (arr[i] != arr[i - 1] && arr[i] == 1) {
      sum = max(sum, min(dem1, dem2) * 2);
      dem1 = 1;
    }
  }
  sum = max(sum, min(dem1, dem2) * 2);
  cout << sum;
  return 0;
}
