#include <iostream>
#include <map>

using namespace std;

int n,m;
map<int,int> c;
long long ans;

int main() {
    c[0] = 1;
    cin >> n >> m;
    int s = 0;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        s = (s+a)%m;
        if (!c.count(s)) {
            c[s] = 1;
        } else {
            ans += c[s];
            c[s]++;
        }
    }
    cout << ans << endl;
}