#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;




int main(){
    ll N, M;
    cin>>N>>M;
    vector<ll> A(N);
    map<ll, ll> B;
    set<ll> Q;
    B[0]=1;
    ll Sum=0;
    rep(i, N){
        cin>>A[i];
        Sum+=A[i];
        Sum%=M;
        Q.insert(Sum);
        B[Sum]++;
    }
    ll Ans=0;
    for (auto itr = Q.begin(); itr != Q.end(); ++itr) {
        Ans+=B[*itr]*(B[*itr]-1)/2;
    }
    cout<<Ans<<endl;
}
    
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define INF (1ll<<60)
#define mod 1000000007
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(ll i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

int main(){
    ll n,m;cin>>n>>m;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];

    pre_process(a,sum);

    vector<ll> cnt;
    rep(i,n+1){
        if(i==0) continue;
        cnt.push_back(sum[i]%m);
    }
    sort(cnt.begin(),cnt.end());
    cnt.push_back(-1ll);

    ll num=1;
    ll answer=0;
    rep(i,cnt.size()-1){
        if(cnt[i]==cnt[i+1]){
            num++;
        }else{
            if(cnt[i]==0){
                answer+=num*(num+1)/2;
            }else{
                answer+=(num-1)*num/2;
            }
            num=1;
        }
    }



    cout<<answer<<endl;
    return 0;
}