#include <cstdio>
#include <unordered_map>
#include <algorithm>
#include <numeric>

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    int b[n+1];
    b[0] = 0;
    for (int i = 1; i <= n; i++) {
        scanf(" %d", b+i);
        b[i] += b[i - 1];
        b[i] %= m;
    }
    std::unordered_map<int, int> mp;
    for (int s : b) {
        mp[s]++;
    }
    unsigned long long ss[mp.size()];
    std::transform(mp.begin(), mp.end(), ss, [](auto p) -> unsigned long long {return (p.second - 1) * p.second / 2;});
    unsigned long long ans = 0;
    for (int i: ss) {
        ans += i;
    }
    printf("%llu\n", ans);
    return 0;
}
