#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;


int sousuu[1000000100] = {0};
int main(){
    int N, M;
    int A[100100];
    cin >> N >> M;
    REP(i, N){
        cin >> A[i];
    }
    int wa = 0;
    sousuu[0] = 1;
    REP(i, N){
        wa = (wa + A[i]) % M;
        sousuu[wa]++;
    }
    ll joukenmitasu = 0;
    REP(i, M){
        joukenmitasu += (sousuu[i] * (sousuu[i] - 1)) / 2;
    }
    
    printf("%lld\n", joukenmitasu);
    
}
