#include <bits/stdc++.h>
using namespace std;
int n, a[100009], b[3];
int main() {
  cin >> n;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] != a[i - 1]) b[a[i]] = 0;
    b[a[i]]++;
    ans = max(ans, min(b[1], b[2]) * 2);
  }
  cout << ans << endl;
  return 0;
}
