#include<iostream>
#include<algorithm>
#include<unordered_map>
using namespace std;

int main(){
    long long N, M, A[100000], sum = 0, ans = 0;
    unordered_map<long long, int> mp;
    cin >> N >> M;
    mp[0] = 1;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        sum += A[i];
        sum %= M;
        ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
    
}