#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, prev = 0, cnt = 0, p = 0, ans = 0, num;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num;
    if (num == prev) {
      cnt++;
    } else {
      p = cnt;
      cnt = 1;
    }
    prev = num;
    ans = max(ans, 2 * min(p, cnt));
  }
  cout << ans << '\n';
  return 0;
}
