#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  int cnt = 1;
  vector<int> ret;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (i == 0) continue;
    if (i and a[i] == a[i - 1])
      cnt++;
    else {
      ret.push_back(cnt);
      cnt = 1;
    }
  }
  ret.push_back(cnt);
  int ans = 0;
  for (int i = 1; i < (int)ret.size(); ++i) {
    ans = max(ans, 2 * min(ret[i], ret[i - 1]));
  }
  cout << ans << endl;
  return 0;
}
