#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, m, sum = 0;
    ll cnt = 0;
    map<int,ll> mp;
    cin >> n >> m;
    mp[0]++;
    REP(i,n){
        int a;
        cin >> a;
        sum = (sum+a)%m;
        cnt += mp[sum];
        mp[sum]++;
    }
    cout << cnt << endl;
    return 0;
}
