#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

void solve() {
    long long N, M, A, s = 0, ans = 0;
    cin >> N >> M;
    map<long long, long long> mp;
    mp[0] = 1;
    rep(i,N) {
        cin >> A;
        s += A;
        s %= M;
        ans += mp[s];
        mp[s]++;
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();
}
