#ifdef LOCAL111 #else #define NDEBUG #endif #include const int INF = 1e9; using namespace std; template ostream& operator<< (ostream& os, const pair& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; } #define endl '\n' #define ALL(a) (a).begin(),(a).end() #define SZ(a) int((a).size()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define RBP(i,a) for(auto& i : a) #ifdef LOCAL111 #define DEBUG(x) cout<<#x<<": "<<(x)< void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;} #else #define DEBUG(x) true template void dpite(T a, T b){ return; } #endif #define F first #define S second #define SNP string::npos #define WRC(hoge) cout << "Case #" << (hoge)+1 << ": " #define rangej(a,b,c) ((a) <= (c) and (c) < (b)) #define rrangej(b,c) rangej(0,b,c) template void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} typedef long long int LL; typedef unsigned long long ULL; typedef pair P; typedef pair LP; void ios_init(){ //cout.setf(ios::fixed); //cout.precision(12); #ifdef LOCAL111 return; #endif ios::sync_with_stdio(false); cin.tie(0); } const LL mod = 1e9+7; //library template class Matrix { public: vector > v; Matrix(int n){ v.resize(n,vector(n,0)); } Matrix operator+ (Matrix x){ Matrix res(v.size()); for(int i = 0; i < (int)v.size(); i++){ for(int j = 0; j < (int)v.size(); j++){ res.v[i][j] = (x.v[i][j]+v[i][j])%mod; } } return res; } Matrix operator-(Matrix x){ Matrix res(v.size()); for(int i = 0; i < (int)v.size(); i++){ for(int j = 0; j < (int)v.size(); j++){ res.v[i][j] = (v[i][j]-x.v[i][j])%mod; } } } Matrix operator*(Matrix x){ Matrix res(v.size()); for(int i = 0;i < (int)v.size(); i++){ for(int j = 0; j < (int)v.size(); j++){ for(int k = 0; k < (int)v.size(); k++){ res.v[i][j] += v[i][k]*x.v[k][j]%mod; res.v[i][j] %= mod; } } } return res; } vector operator*(vector x){ assert(x.size() == v.size()); vector res(v.size()); for(int i = 0; i < (int)v.size(); i++){ T tmp = 0; for(int j = 0; j < (int)v.size(); j++){ tmp += v[i][j]*x[j]%mod; tmp %= mod; } res[i] = tmp; } return res; } vector& operator[](int x){ return v[x]; } }; template Matrix pow(Matrix x,long long n){ Matrix tmp = x, res(SZ(x.v)); for(int i = 0; i < SZ(x.v); i++) res.v[i][i] = 1; while(n != 0){ if(n&1){ res = res*tmp; } tmp = tmp*tmp; n >>= 1; } return res; } //libary int main() { ios_init(); int n; LL k; while(cin >> n >> k) { DEBUG(n); vector a(n); REP(i,n) cin >> a[i]; function solvemat = [&](){ Matrix A(n); REP(i,n) A[0][i] = 1; REP(i,n-1) A[i+1][i] = 1; Matrix B(n+1); B[0][0] = B[0][1] = 1; REP(i,n) B[1][i+1] = 1; REP(i,n-1) B[i+2][i+1] = 1; REP(i,n+1) dpite(ALL(B[i])); if(k <= n){ k--; cout << a[k] << ' ' << accumulate(a.begin(),a.begin()+k,0LL) << endl; }else{ A = pow(A,k-n); vector b = a; b.push_back(accumulate(a.begin(),--a.end(),0LL)); reverse(ALL(a)); auto ans = A*a; // reverse(ALL(a)); reverse(ALL(b)); dpite(ALL(b)); B = pow(B,k-n+1); auto ans2 = B*b; dpite(ALL(ans2)); cout << ans[0] << ' ' << ans2[0] << endl; } }; function solvedp = [&](){ if(k <= n){ cout << a[k-1] << endl; }else{ vector dp(k,0); LL sum = 0; REP(i,SZ(a)){ sum = (sum+a[i])%mod; dp[i]= a[i]; } FOR(i,n,k){ dp[i] = sum; sum = ((sum-dp[i-n]+mod)%mod+dp[i])%mod; } LL ans = 0; REP(i,k){ ans = (ans+dp[i])%mod; } cout << dp[k-1] << ' ' << ans << endl; } }; if(n <= 31){ solvemat(); }else{ solvedp(); } } return 0; }