#include using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; const int MOD7 = ( int ) 1e9 + 7; int N; ll K; vi A; void init(){ cin >> N >> K; A = vi( N ); for( int i = 0; i < N; ++i ){ cin >> A[ i ]; } } void preprocess(){ } vvi mat_mul( vvi a, vvi b ){ vvi c( a.size(), vi( b[ 0 ].size() ) ); for( int i = 0; i < a.size(); ++i ){ for( int j = 0; j < a[ 0 ].size(); ++j ){ for( int k = 0; k < b[ 0 ].size(); ++k ){ ( c[ i ][ k ] += 1LL * a[ i ][ j ] * b[ j ][ k ] % MOD7 ) %= MOD7; } } } return c; } vvi mat_pow( vvi a, ll p ){ vvi res = vvi( a.size(), vi( a[ 0 ].size() ) ); for( int i = 0; i < a.size(); ++i ){ res[ i ][ i ] = 1; } while( p ){ if( p & 1LL ){ res = mat_mul( res, a ); } p >>= 1; a = mat_mul( a, a ); } return res; } void solve(){ if( K < ( int ) 1e7 ){ deque< int > dq; int cur_val = 0; int sum_val = 0; for( int i = 0; i < N; ++i ){ dq.emplace_back( A[ i ] ); ( cur_val += A[ i ] ) %= MOD7; ( sum_val += A[ i ] ) %= MOD7; } ( sum_val += cur_val ) %= MOD7; for( int i = 0; i < K - 1 - N; ++i ){ ( cur_val += cur_val ) %= MOD7; ( cur_val -= dq.front() ) %= MOD7; ( sum_val += cur_val ) %= MOD7; dq.pop_front(); dq.emplace_back( cur_val ); } if( cur_val < 0 ){ cur_val += MOD7; } if( sum_val < 0 ){ sum_val += MOD7; } cout << cur_val << " " << sum_val << endl; } else{ vvi feature( N + 1, vi( N + 1 ) ); for( int i = 0; i < N; ++i ){ feature[ 0 ][ i ] = 1; } for( int i = 0; i + 1 < N; ++i ){ feature[ i + 1 ][ i ] = 1; } for( int i = 0; i <= N; ++i ){ feature[ N ][ i ] = 1; } vvi a( N + 1, vi( 1 ) ); for( int i = 0; i < N; ++i ){ a[ i ][ 0 ] = A[ N - 1 - i ]; } for( int i = 0; i < N; ++i ){ ( a[ N ][ 0 ] += A[ i ] ) %= MOD7; } a = mat_mul( mat_pow( feature, K - N ), a ); int cur_val = a[ 0 ][ 0 ] < 0 ? a[ 0 ][ 0 ] + MOD7 : a[ 0 ][ 0 ]; int sum_val = a[ N ][ 0 ] < 0 ? a[ N ][ 0 ] + MOD7 : a[ N ][ 0 ]; for( int i = 0; i <= N; ++i ){ cout << a[ i ][ 0 ] << endl; } cout << cur_val << " " << sum_val << endl; } } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }