#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N, M, a, s = 0;
    cin >> N >> M;
    map<ll, int> c;
    c[0]++;
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        s += a;
        s %= M;
        ans += c[s];
        c[s]++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}