#include #define EPS 1e-9 #define INF 1070000000LL #define MOD 1000000007LL #define fir first #define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++) #define numa(x,a) for(auto x: a) #define ite iterator #define mp make_pair #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define pb push_back #define pf push_front #define sec second #define sz(x) ((int)(x).size()) #define ALL( c ) (c).begin(), (c).end() #define gcd(a,b) __gcd(a,b) #define mem(x,n) memset(x,n,sizeof(x)) #define endl "\n" using namespace std; template void deploy(std::ostream &os, const TUPLE &tuple){} template void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get(t); deploy(os, t); } template std::ostream& operator<<(std::ostream &os, std::pair &p){ os << "(" << p.first <<", " << p.second <<")";return os; } template std::ostream& operator<<(std::ostream &os, std::vector &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template std::ostream& operator<<(std::ostream &os, std::set &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template std::ostream& operator<<(std::ostream &os, std::map &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; } #define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; } #define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); } #define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); } #define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); } using ll = long long; pair solve(int N,int K){ //naive vector nums(N+1); rep(i,N){ cin >> nums[i+1]; } vector memo(K+5,0); pair ans; for (int i = 1; i <= K; i++) { if (i <= N) { memo[i] = nums[i]; }else{ if (i == N + 1) { memo[i] = ans.sec; }else{ memo[i] = memo[i-1]; memo[i] -= memo[i-N-1]; memo[i] += memo[i-1]; memo[i] %= MOD; } } ans.sec += memo[i]; ans.sec %= MOD; } ans.fir = memo[K]; return ans; } /*行列*/ typedef vector vec; typedef vector mat; const ll M = MOD; mat mul(mat &A,mat &B){//行列掛け算 A*B mat C(sz(A), vec(sz(B[0]),0)); rep(i,sz(A)){ rep(k,sz(B)){ rep(j,sz(B[0])){ C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % M; } } } return C; } mat pow(mat A,ll n){ mat B(sz(A),vec(sz(A),0)); rep(i,sz(B)){ B[i][i] = 1; } while(n > 0){ if(n & 1){ B = mul(B,A); } A = mul(A,A); n >>= 1; } return B; } pair solve2(ll N,ll K) { vector nums(N); rep(i,N){ cin >> nums[i]; } //DEBUG1(nums); vector init(N+1); init[0] = 0; for (int i = 1; i <= N; i++) { init[i] = nums[i-1]; } mat A(N+1,vec(N+1,0)); A[0][0] = 1; A[0][1] = 1; for (int i = 1; i <= N-1; i++) { A[i][i+1] = 1; } for (int i = 1; i<= N; i++) { A[N][i] = 1; } auto X = pow(A,K-1); ll S = 0; //DEBUG1(X); rep(i,N+1){ S += (X[0][i] * init[i]) % MOD; //DEBUG2(X[0][i],init[i]); S %= MOD; } ll Ak = 0; rep(i,N+1){ Ak += (X[1][i] * init[i]) % MOD; //DEBUG2(X[1][i],init[i]); Ak %= MOD; } S += Ak; S %= MOD; return mp(Ak,S); } int main() { cin.tie(0); ios_base::sync_with_stdio(0); ll N,K; cin >> N >> K; pair ans; if (N > 30 || K <= 100){ ans = solve(N,K); }else{ ans = solve2(N,K); } cout << ans.fir << " " << ans.sec << endl; return 0; }