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

#define For(i,a,b) for(int (i) = (a);(i) < (b);i += 1)
#define Rep(i,n) For((i),0,(n))
#define All(a) (a).begin(),(a).end()
#define sp " "
#define INF 1e18
#define INT_INF 1e9
#define MAX_N 100000

typedef long long ll;
const ll MOD = 1000000007;
const ll MOD_9 = 998244353;

int main(){
    ll N,M;
    cin >> N >> M;
    ll A[N];
    vector<ll> Sum(N);
    Rep(i,N){
        cin >> A[i];
        if(i != 0)Sum[i] = Sum[i-1] + A[i];
        else Sum[i] = A[i];
        Sum[i] %= M;
        //cout << Sum[i] << endl;
    }
    sort(All(Sum));
    ll cnt = 1;
    ll ans = 0;
    Rep(i,N){
        if(Sum[i] == 0)ans++;
    }
    Rep(i,N-1){
        if(Sum[i] == Sum[i+1]){
            cnt++;
        }else if{
            ans += (cnt*(cnt-1))/2;
            cnt = 1;
        }
    }
    ans += (cnt*(cnt-1))/2;
    cout << ans;
    //cin >> N;
}