#include <bits/stdc++.h>

using namespace std;

using i64 = int64_t;

#define FOR(i,start,end) for(int i=(start); i<(end); ++i)
#define REP(i,n) FOR(i,0,n)

i64 N;
i64 M;
vector<i64> A;

void solve() {
    vector<i64> sum(N+1, 0);
    partial_sum(begin(A), end(A), begin(sum)+1);
    transform(begin(sum), end(sum), begin(sum), [](auto e) { return e%M; });

    unordered_multiset<i64> ms(begin(sum), end(sum));
    i64 ans = 0;
    for(auto e : sum) {
        ans += ms.count(e) - 1;
        ms.erase(ms.find(e));
    }

    cout << ans << "\n";
}

int main() {
    cin >> N;
    A.resize(N);
    cin >> M;

    REP(i, N) {
        cin >> A[i];
    }

    solve();
}
