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

int sum, ans;
signed main(){
    
    int n,m;
    cin >> n >> m;

    map<int,int>mp;
    mp[0] = 1;
    for(int i = 0;i<n;i++){
        int a;
        cin >> a;

        sum+=a;
        ans+=mp[sum%m];
        mp[sum%m]++;
    }

    cout << ans << endl;
    return 0;
}
