#include <bits/stdc++.h>
using namespace std;

int main(){
    long long n,m;
    long long ans=0;
    cin>>n>>m;
    map<long long,long long> c;
    long long s=0;
    for (int i = 0; i < n; ++i) {
        int t;
        cin>>t;
        s+=t;
        ++c[s%m];
    }
    for (auto i:c) {
        long long t=i.second;
        ans+=t*(t-1)/2;
    }
    ans+=c[0];
    cout<<ans<<endl;
    return 0;
}