#include #include #include #include #include #include #include #include #include #define reps(i,f,n) for(int i=f;i >{ public: P(int n){ rep(i,n){ vector dat(n); this->pb(dat); } } }; class V:public vector{ public: V(int n){ rep(i,n)this->pb(0); } }; P multi(P& a, P& b){ int n = a.size(); P ret(n); rep(i,n){ rep(j,n){ int num = 0; rep(k,n){ num = (num+a[i][k]*b[k][j])%MOD; } ret[i][j] = num; } } return ret; } V multi(P& a, V& b){ int n = a.size(); V ret(n); rep(i,n){ int num = 0; rep(j,n){ num = (num+a[i][j]*b[j])%MOD; } ret[i] = num; } return ret; } P getP(int n){ P ret(n+1); rep(i,n-1){ rep(j,n){ if(j-1==i)ret[i][j]=1; else ret[i][j] = 0; } } rep(i,n)ret[n-1][i]=1; rep(i,n)ret[i][n]=0; rep(i,n+1)ret[n][i]=1; return ret; } void print(P& a){ rep(i,a.size()){ rep(j,a.size()){ printf("%d ",a[i][j]); }puts(""); } } void print(V& a){ rep(i,a.size()){ printf("%d ",a[i]); }puts(""); } int main(){ ll n,k; cin>>n>>k; vector a(n); rep(i,n)cin>>a[i]; int ansF = -1; int ansS = -1; if(n<=30){ const int T = 50; vector

b; b.pb(getP(n)); reps(i,1,T){ b.pb(multi(b[i-1], b[i-1])); } V vec(n+1); rep(i,n)vec[i] = a[i]; rep(i,n)vec[n] = (vec[n]+a[i])%MOD; ll tk = k-n; ll sc = 1; rep(i,T){ if((tk&sc)>0){ vec = multi(b[i], vec); } sc*=2; } ansF = vec[n-1]; ansS = vec[n]; }else{ deque b; rep(i,n)b.pb(a[i]); ll sum = 0; rep(i,n)sum += a[i]; ll allsum = sum; rep(i,k-n){ allsum += sum; b.pb(sum); ansF = sum; sum = (sum+sum-b[0]+MOD)%MOD; b.pop_front(); } ansS = allsum; } cout<