#include <bits/stdc++.h>
#define intt long long
using namespace std;
const int maxx = 1e5+5;
int i , j ;
int a[maxx];
map <int,int> mp;
int main ()
{
    int n,m , cnt = 0;
    cin >> n>> m;
    intt res =0 , ans = 0 ;
    mp[0] =1;
    for ( i =1  ; i <= n;  i++ )
    {
        cin >> a[i];
        res += a[i];
        ans += mp[res%m];
        mp[res%m]++;
    }
    cout << ans << endl;
}
