int main(){
    int N,M,i,t;
    cin >> N >> M;
    vector<int> S(N+1);//sum of l~r : s[r]-s[l-1] 
    S[0]=0;
    for(i=1;i<=N;i++){
        cin >> t;
        t %= M;
        t += S.at(i-1);
        S.at(i) = t % M;
    }
    sort(S.begin(),S.end());
    int l,r;
    long long int ans;
    ans = 0;
    for(l=0;l<N;l++){
        for(r = l+1; r < N+1; r++){
            if(S.at(r)==S.at(l)) ans++;
            if(S.at(r)>S.at(l)) continue;
        }
    }
    cout << ans << endl;
    return 0;
}