#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 * 1000 + 10;
int n, t[MAXN];
vector<int> v;
int main() {
  cin >> n >> t[0];
  v.push_back(1);
  for (int i = 1; i < n; i++) {
    cin >> t[i];
    if (t[i] == t[i - 1])
      v[(int)v.size() - 1]++;
    else
      v.push_back(1);
  }
  int ans = 0;
  for (int i = 0; i < (int)v.size() - 1; i++) {
    ans = max(ans, 2 * min(v[i], v[i + 1]));
  }
  cout << ans << endl;
  return 0;
}
