#include<bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

map<ll,int> mp;

int n,m;
ll s,ans;

int main()
{
    scanf("%d%d",&n,&m);
    mp[0]=1;
    for(int i=1,x;i<=n;i++)
    {
        scanf("%d",&x);
        s+=x;s%=m;
        ans+=mp[s];
        mp[s]++;
    }
    printf("%lld\n",ans);
}
