#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    map<long long, int> cnt;
    cnt[0]++;
    long long acc = 0, res = 0;
    for (int i = 0; i < n; i++) {
        acc += a[i];
        res += cnt[acc % m]++;
    }
    cout << res << endl;
    return 0;
}