#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wfloat-conversion"

#include <iostream> // IO
#include <cmath> // sqrt, trig, ceil, log
#include <utility> // swap, pair 
// #include <chrono> // non c style time

// #include <algorithm> // sort, binary search, reverse, merge
// #include <bitset>
// #include <cstdio> 
// #include <cstdlib> //abs, atoi, rand 
// #include <iterator> 
// #include <map>  
// #include <queue>
// #include <set> 
// #include <stack> 
// #include <string> // std string
// #include <vector> 

// #include <complex>
// #include <deque>
// #include <iomanip> // setprecision
// #include <tuple>

#define fo(i, a, b) for(i=a; i<=b; i++)
#define ro(i, b, a) for(i=b; i>=a; i--)
#define foe(it, x) for(auto it=x.begin(); it!=x.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define fil(x, y) memset(x, y, sizeof(x))
#define deb(x) cout << #x << " " << x << "\n"
#define sz(a) ((int)(a.size()))

using namespace std;

using ll = long long;

const ll N = 3e3+3;
const int inf = 1e9+3;
const ll M = 1e9+7;
const ll T = 998244353;
const double pi = acos(-1);

void solve()
{
    ll n,i,j,ans=0;cin>>n;
    ll dp[n+1][n+1];
    ll a[n+1];
    ll p[n+1];
    p[0]=0;
    fo(i,1,n){
        cin>>a[i];
        p[i]=p[i-1]+a[i];
    }
    fo(i,0,n){
        fo(j,0,n){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(j=1;j<=n;j++){
        ll adj[n+1];
        fo(i,0,n){
            adj[i]=0;
        }
        for(i=0;i<=n;i++){
            dp[i][j]=(dp[i][j]+(adj[p[i]%j]))%M;
            adj[p[i]%j]=(adj[p[i]%j]+dp[i][j-1])%M;
        }
    }
    for(j=1;j<=n;j++){
        ans=(ans+dp[n][j])%M;
    }
    cout << ans << "\n";
}

signed main()
{
    // auto s1 = std::chrono::system_clock::now().time_since_epoch();
    // auto start_time = std::chrono::duration_cast<std::chrono::microseconds>(s1).count();

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifdef Holmes7 
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif

    int _t=1,i;
    //cin >> _t;
    for(i=1;i<=_t;i++){
        //cout << "Case #" << i << ": ";
        solve();
    }

    // auto s2 = std::chrono::system_clock::now().time_since_epoch();
    // auto end_time = std::chrono::duration_cast<std::chrono::microseconds>(s2).count();
    // cerr << "Time: " << (end_time-start_time) << "\n";

    return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>
#include<time.h>



#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define sz(a) ((int)a.size())
#define getmid ((l+r)>>1)
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define lowbit(x) x&(-x)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
using namespace std;
#ifdef local
#define dbg(args...) cout << #args << " -> ", err(args);
void err(){ cout << endl; }
template<typename T, typename... Args>
void err(T a, Args... args){ cout << a << ' '; err(args...); }
#else
#define dbg(args...)
#endif // local

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <double, double> pdd;
const int inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-8;
const int mod=998244353;
const int maxn=2e5+100;
const int N=2e5+100;
const int M=(1<<20)+10;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x)
{
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar())
        f ^= c == '-';
    for (; isdigit(c); c = getchar())
        x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x)
{
    if (x < 0)
    {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10)
        ++len;
    for (; len; --len, x %= y, y /= 10)
        putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%mod;
        b>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

int inv[N],fac[N];
void init()
{
    fac[0]=1;
    for(int i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%mod;
    inv[N-1]=qpow(fac[N-1],mod-2,mod);
    for(int i=N-2;i>=0;--i) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int n,int m)
{
    return 1ll*fac[n]*inv[n-m]%mod*inv[m]%mod;
}
int a[N],pw[N][305];
int n,k;
void solve(int x)
{
    int tmp=0;
    for(int i=1;i<=n;++i) tmp=(tmp+qpow(2*a[i],x,mod))%mod;
    ll ans=0;
    for(int i=0;i<=x;++i)
    {
        ans=(ans+1ll*C(x,i)*pw[n][i]%mod*pw[n][x-i])%mod;
    }
    ans=(ans-tmp+mod)%mod;
    ans=ans*inv[2]%mod;
    cout<<ans<<"\n";
}
int main()
{
#ifdef local
    freopen("in.txt","r",stdin);
#endif // local
    IOS;cout.tie(0);
    init();
    cin>>n>>k;
    rep1(i,n) cin>>a[i];
    for(int y=0;y<=k;++y)
    {
        for(int i=1;i<=n;++i)
            pw[i][y]=(pw[i-1][y]+qpow(a[i],y,mod))%mod;
    }
    rep1(i,k) solve(i);
    return 0;
}

