#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
#define set(i) setprecision(i)
using namespace std;

signed main(){
    int n,m; cin>>n>>m;
    map<int, int> rem;
    rem[0]++;
    int sum=0;
    rep(i,n){
        int a; cin>>a;
        sum+=a;
        rem[sum%m]++;
    }
    int ans=0;
    rep(i,rem.size()){
        ans+=(rem[i]-1)*rem[i]/2;
    }
    cout<<ans<<endl;
