#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000 int main(){ int D; cin>>D; vector a(D+1); rep(i,D+1)cin>>a[i]; while(a.size() >= 4){ long long t = a.back(); a.pop_back(); a[a.size()-2] += t; } while(a.size()>0&&a.back()==0)a.pop_back(); if(a.size()==0)a.push_back(0); cout<