#include<bits/stdc++.h>
using namespace std;
int n;
long long m;
map<long long,long long>mp;
long long a[100005];
int main()
{
    scanf("%d%lld",&n,&m);
    long long res=0,ans=0;
    mp[0]=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        res=(res+a[i])%m;
        ans+=mp[res];
        mp[res]++;
    }
    cout<<ans<<endl;
}