#ifndef _GLIBCXX_NO_ASSERT #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #endif // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define revrep(i, n) for(int i = n-1; i >= 0; i--) typedef long long ll; typedef pair Pint; typedef pair P; typedef vector vec; typedef vector mat; //typedef pair> P; //typedef tuple T; ll INFL = 1000000000000000010;//10^18 = 2^60 int INF = 1000000000;//10^9 ll MOD = 1000000007; //vector dy = {0,0,1,-1}; //vector dx = {1,-1,0,0}; mat mul_mat(mat &A, mat &B){ mat res(A.size(), vec(B[0].size())); rep(i, A.size())rep(k, B.size())rep(j, B[0].size()){ res[i][j] = (res[i][j] + (A[i][k] * B[k][j]) % MOD) % MOD; } return res; } mat pow_mat(mat &A, ll n){ mat res(A.size(), vec(A.size())); rep(i, A.size()) res[i][i] = 1; while(n > 0){ if(n&1) res = mul_mat(res, A); A = mul_mat(A, A); n >>= 1; } return res; } int main(void){ ll N, K; cin >> N >> K; vec A(N); rep(i, N) cin >> A[i]; if(K <= N){ cout << A[K] << endl; ll S = 0; rep(i, K){ S = (S + A[i]) % MOD; } cout << S << endl; return 0; } mat a(N, vec(N, 0)); rep(i, N) a[i][0] = 1; rep(i, N-1) a[i][i+1] = 1; mat a_ = a; a = pow_mat(a, K-N); ll F = 0; rep(i, N){ F = (F + A[N-1-i] * a[i][0]) % MOD; } mat b(2*N, vec(2*N, 0)); rep(i, N)rep(j, N){ b[i][j] = a_[i][j]; if(i == j){ b[i+N][i] = 1; b[i+N][i+N] = 1; } } b = pow_mat(b, K-N+1); b[N][0]--; ll S = 0; rep(i, N){ S = (S + A[N-1-i] * (b[i+N][0])) % MOD; S = (S + A[i]) % MOD; } S = (S + MOD) % MOD; cout << F << " " << S << endl; }