#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define indexOf(v,x) (find(all(v),x)-v.begin()) #define MOD 1000000007 template class Matrix{ int _row,_col; T* p; public: Matrix():_row(0),_col(0),p(0){} Matrix(int row,int col):_row(row),_col(col){ p=new T[_row*_col]; } Matrix(const Matrix& a):_row(-1),p(0){ copy(a); } ~Matrix(){ delete[] p; } int row()const{return _row;} int col()const{return _col;} void resize(int r,int c){ if(_row*_col!=r*c){ delete[] p; p=new T[r*c]; } _row=r; _col=c; } void swap(Matrix& a){ std::swap(_row,a._row); std::swap(_col,a._col); std::swap(p,a.p); } void copy(const Matrix& a){ resize(a._row,a._col); for(int i=0;i>=1; } return res; } }; int F1(int n,int k,int a[]){ int s=0; rep(i,n)(s+=a[i])%=MOD; for(int i=n;i mat(n,n),b(1,n); rep(i,n)rep(j,n)mat[i][j]=j==0||i+1==j; rep(i,n)b[0][i]=a[n-1-i]; return (b*mat.pow(k-n))[0][0]; } int S2(int n,long long k,int a[]){ Matrix<> mat(n+1,n+1),b(1,n+1); rep(i,n+1)rep(j,n+1)mat[i][j]=0; rep(i,n)rep(j,n)mat[i][j]=j==0||i+1==j; rep(i,n+1)mat[i][n]=1; rep(i,n)b[0][i]=a[n-1-i]; b[0][n]=0; int ans=0; rep(i,n)(ans+=a[i])%=MOD; ans+=(b*mat.pow(k-n))[0][n]; return ans%MOD; } int a[1000000]; int main(){ long long n,k; cin>>n>>k; rep(i,n)cin>>a[i]; if(0&&n<=10000&&k<=1000000)cout<