#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 123456;
int n, t[MAX_N];
int main() {
  cin >> n;
  int tuna = 0, eel = 0, subsequence = 0, max_subsequence = 0;
  for (int i = 0; i < n; ++i) {
    cin >> t[i];
    if (i != 0 && t[i] == 1 && t[i - 1] == 2 && tuna != 0) {
      subsequence = 2 * min(tuna, eel);
      if (subsequence > max_subsequence) max_subsequence = subsequence;
      tuna = 0;
    } else if (i != 0 && t[i] == 2 && t[i - 1] == 1 && eel != 0) {
      subsequence = 2 * min(tuna, eel);
      if (subsequence > max_subsequence) max_subsequence = subsequence;
      eel = 0;
    }
    if (t[i] == 1)
      tuna++;
    else if (t[i] == 2)
      eel++;
  }
  subsequence = 2 * min(tuna, eel);
  if (subsequence > max_subsequence) max_subsequence = subsequence;
  cout << max_subsequence << endl;
  return 0;
}
