#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<LL> a(N+1, 0);
    for (i=0;i<n;i++){
        cin >> a[i+1];
        a[i+1] += a[i];
    }
    for(i=0;i<n+1;i++) a[i] %= M;
    sort(a.begin(),a.end());
    LL now = 0, ct = 0;
    LL ans = 0;
    for(i=0;i<n+1;i++){
        if(i == N || now != a[i]){
            if(i == N && now == a[i]) ct++;
            now = a[i];
            ans += ct*(ct-1)/2;
            ct = 1;
        }else{
            ct++;
        }
    }
    cout << ans << endl;
    return 0;
}