#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


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