#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=100,maxm=499950;

int n,K,MOD,f[maxn+5][maxm+5],F[maxn+5];

int main(){
	scanf("%d%d%d",&n,&K,&MOD);f[0][0]=1;
	for (int i=1,sum=i*K;i<=n;i++,sum+=i*K){
		for (int j=0;j<i;j++) F[j]=0;
		for (int j=0;j<=sum;j++){
			F[j%i]=(F[j%i]+f[i-1][j])%MOD;
			if (j>=i*(K+1)) F[j%i]=(F[j%i]+MOD-f[i-1][j-i*(K+1)])%MOD;
			f[i][j]=F[j%i];
		}
	}
	for (int x=1;x<=n;x++){
		int ans=MOD-1;
		for (int j=0;j<=maxm;j++) ans=(ans+(LL)f[x-1][j]*f[n-x][j]%MOD*(K+1)%MOD)%MOD;
		printf("%d\n",ans);
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

long long mod = 1000000007;
long long N;
long long A[1 << 18];
long long dp1[1 << 18][2];
long long dp2[1 << 18][2];

int main(){
  cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];

	dp1[1][0] = 1;
	dp2[1][0] = A[1];
	for (int i = 2; i <= N; i++) {
		for (int j = 0; j <= 1; j++) {
			// + を選ぶ場合
			dp1[i][0] += dp1[i - 1][j];
			dp2[i][0] += dp2[i - 1][j] + dp1[i - 1][j] * A[i];
			dp1[i][0] %= mod;
			dp2[i][0] %= mod;

			// - を選ぶ場合
			if (j == 0) {
				dp1[i][1] += dp1[i - 1][j];
				dp2[i][1] += dp2[i - 1][j] - dp1[i - 1][j] * A[i];
				dp1[i][1] %= mod;
				dp2[i][1] = (dp2[i][1] + mod * mod) % mod;
			}
		}
	}
	cout << (dp2[N][0] + dp2[N][1]) % mod << endl;

  return 0;
}
