#include <bits/stdc++.h>

using namespace std;

const int MOD = 1000000007;
const int N = 3005;

long long a[N];
int f[2][N];
int cnt[N];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int flag = 0;
	for (int i = 1; i <= n; i++) f[flag][i] = 1;
	int res = 1;
	for (int j = 2; j <= n; j++) {
		int cur = 0;
		int old = flag;
		flag ^= 1;
		for (int i = 0; i < j; i++) cnt[i] = 0;
		for (int i = 1; i <= n; i++) {
			cur = (cur + a[i] % j) % j;
			f[flag][i] = cnt[cur];
			if (f[old][i]) {
				cnt[cur] += f[old][i];
				if (cnt[cur] >= MOD) cnt[cur] -= MOD;
			}
		}
		res += f[flag][n];
		if (res >= MOD) res -= MOD;
	}
	cout << res << "\n";
}

#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

// auto mod int
//const int mod = 1000000007;
//const int mod = 998244353;
int mod;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  //mint inv() const { return pow(mod-2);}

  //supports not prime
  mint modinv(ll a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    mint res(u);
    return res;
}
  mint& operator/=(const mint a) { return *this *= modinv(a.x);}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int N,K;
    cin>>N>>K>>mod;

    int MX=N*(N+1)*K/2+1;

    vector<vector<mint>> dp(N+1, vector<mint> (MX));
    dp[0][0]=1;
    int s=0;
    for(int i=1;i<=N;i++){
        vector<mint> ps(i);
        s+=i;
        for(int j=0;j<=s*K;j++){
            int x=j%i;
            ps[x]+=dp[i-1][j];
            if(j-i*(K+1)>=0){
                ps[x]-=dp[i-1][j-i*(K+1)];
            }
            dp[i][j]=ps[x];
        }
    }

    s=0;

    for(int i=1;i<=N;i++){
        s+=i;
        mint ans;
        for(int t=0;t<=s*K;t++){
            ans+=dp[i-1][t]*dp[N-i][t];
        }
        ans=ans*(K+1)-1;
        cout<<ans<<endl;
    }
    
    return 0;
}