class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n using namespace std; typedef long long i64; const i64 MOD = 1e9 + 7; typedef vector vec; typedef vector mat; //A * B mat mat_mul(const mat& A, const mat& B) { mat C(A.size(), vec(B.size())); for(size_t i = 0; i < A.size(); ++i) for(size_t k = 0; k < B.size(); ++k) for(size_t j = 0; j < B[0].size(); ++j) C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD; return C; } //A ^ n mat mat_pow(mat A, i64 n) { mat B(A.size(), vec(A.size())); for(size_t i = 0; i < A.size(); ++i) B[i][i] = 1LL; while(n > 0) { if(n & 1LL) B = mat_mul(B, A); A = mat_mul(A, A); n >>= 1LL; } return B; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n; i64 k; cin >> n >> k; if(n > 30) { vector a(n); for(auto& x : a) cin >> x; vector f(k, 0LL), s(k, 0LL); for(int i : in(k)) { if(i < n) { f[i] = a[i]; s[i] = a[i] + (i == 0 ? 0LL : s[i - 1]); continue; } f[i] = s[i - 1] - (i == n ? 0LL : s[i - n - 1]); s[i] = s[i - 1] + f[i]; (f[i] += MOD) %= MOD; (s[i] += MOD) %= MOD; } cout << f.back() << ' ' << s.back() << endl; return 0; } vector a(n + 1, 0LL); for(int i : in(1, n + 1)) cin >> a[i]; mat s(n + 1, vec(n + 1, 0LL)); s[0][0] = 2LL; s[0][n] = -1LL; for(int i : in(n)) s[i + 1][i] = 1LL; s = mat_pow(s, k - n); for(int i : in(n)) a[i + 1] += a[i]; reverse(a.begin(), a.end()); i64 sk = [&]() { i64 res = 0LL; for(int j : in(n + 1)) (res += s[0][j] * a[j] % MOD + MOD) %= MOD; return res; }(); i64 sk_1 = [&]() { i64 res = 0; for(int j : in(n + 1)) (res += s[1][j] * a[j] % MOD + MOD) %= MOD; return res; }(); cout << (sk + MOD - sk_1) % MOD << ' ' << (sk + MOD) % MOD << endl; return 0; }