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

int main() {
    ll n, m;   cin >> n >> m;
    map<ll, ll> remain;
    ll sum = 0, ele = 0, result = 0;
    for(int i = 0; i < n; ++i) {
        cin >> ele;
        sum += ele;
        sum %= m;

        if(sum == 0)  result += 1;
        result += remain[sum];
        remain[sum]++;
    }
    cout << result << endl;

    return 0;
}