#include "bits/stdc++.h"
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector< int> in(n);
    for (int &i : in) {
        cin >> i;
        i %= k;
    }
    long long res = 0;
    map< int, int> mp;
    int s = 0;
    for(int i = 0; i < n; ++i) {
       mp[s]++;
       s += in[i];
       s %= k;
       res += mp[s];
    }

    printf("%lld\n", res);
}