#include using namespace std; typedef long long ll; typedef vector vec; typedef vector mat; const ll mod = 1e9 + 7; mat mul(mat &A, mat &B) { mat res(A.size(), vec(B[0].size())); for (int i = 0; i < A.size(); i++) { for (int k = 0; k < B.size(); k++) { for (int j = 0; j < B[0].size(); j++) { res[i][j] = (res[i][j] + A[i][k] * B[k][j]) % mod; } } } return res; } mat id(int n) { mat res(n, vec(n)); for (int i = 0; i < n; i++) { res[i][i] = 1; } return res; } mat pow(mat A, ll n) { mat res = id(A.size()); while (n > 0) { if (n & 1) res = mul(res, A); A = mul(A, A); n >>= 1; } return res; } mat companion(vector c) { int n = c.size(); mat res(n + 1, vec(n + 1)); for (int i = 0; i < n; i++) { res[n - 1][i] = c[n - i - 1]; } for (int i = 0; i < n - 1; i++) { res[i][i + 1] = 1; } res[n][n - 1] = 1; res[n][n] = 1; return res; } ll N, K; vector iv; ll fib[10000]; void solve1() { vector cf; for (int i = 0; i < N; i++) { cf.push_back(1); } mat cp = companion(cf); cp = pow(cp, K - N + 1); ll ans = 0; ll sum = 0; for (int i = 0; i < N - 1; i++) { sum += iv[i]; } sum %= mod; iv.push_back(sum); sum = 0; for (int i = 0; i <= N; i++) { ans += cp[N - 2][i] * iv[i]; sum += cp[N][i] * iv[i]; ans %= mod; sum %= mod; } cout << ans << " " << sum << endl; } void solve2() { ll ans = 0; ll sum = 0; for (int i = 0; i < N; i++) { fib[i] = iv[i]; sum += iv[i]; } sum %= mod; ll temp = sum; for (int i = N; i < K; i++) { fib[i] = temp; temp += fib[i]; temp -= fib[i - N]; sum += fib[i]; sum %= mod; } cout << fib[K - 1] << " " << sum << endl; } int main() { cin >> N >> K; for (int i = 0; i < N; i++) { ll a; cin >> a; iv.push_back(a); } if (N <= 30) { solve1(); } else { solve2(); } }