#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx2") #include using namespace std; int a[200001], b[200001]; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; for(int i = 0; i < 2 * n + 1; i++) cin >> a[i]; while(n--) { for(int i = 0; i < n * 2 + 1; i++) { b[i] = a[i] + a[i + 1] + a[i + 2] == 3 ? a[i + 1] - a[i] == 1 or a[i + 1] - a[i] == -2 ? 1 : 2 : 0; } swap(a, b); } cout << a[0] << endl; }