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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n];
    int s[n + 1] = {};
    for(int i=0;i<n;i++) {
        cin >> a[i];
        s[i + 1] = (s[i] + a[i]) % m;
    }
    map<int, int> mp;
    for(int i=0;i<=n;i++) { mp[s[i]]++; }
    int ans = 0;
    for (auto p : mp) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << "\n";
}