#include <iostream>
#include <map>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    map<int, int> count;
    int64_t answer = 0;
    count[0] = 1;
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int x; cin >> x;
        sum = (sum + x) % M;

        answer += count[sum];
        count[sum]++;
    }

    cout << answer << "\n";
}
