#include <bits/stdc++.h>
using namespace std;
long long if_1(vector<long long>& vec, int n) {
  vector<long long> count(2);
  long long res = 0, it = 0;
  for (int i = 0; i < n; i++) {
    if (it % 2 == vec[i] % 2) {
      count[it] += 1;
    } else {
      res = max(res, 2ll * min(count[1], count[0]));
      count[vec[i] % 2] = 1;
      it = vec[i] % 2;
    }
  }
  res = max(res, 2ll * min(count[1], count[0]));
  return res;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  long long res = if_1(vec, n);
  cout << res << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long tc = 1, count = 1;
  while (tc--) {
    cout << fixed << setprecision(0);
    solve();
  }
  return 0;
}
