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