#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>

using namespace std;
void func() {
    int N,M;
    cin >> N >> M ;
    int sum = 0;
    int ans = 0;
    map<int ,int> counter;
    counter[0] = 0;
    for (int i = 0; i < N; ++i) {
        int a ;
        cin >> a;
        sum += a;
        sum %= M;
        if(counter[sum]) {
            ans += couter[sum];
            couter[sum] += 1;
        } else {
            couter[sum] = 1;
        }
    }
    cout << ans << endl;
}

int main() {
    func();
    return 0;
}