#include <iostream>
#include <map>

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    map<int, int> f;
    int s = 0;
    f[0] = 1;
    long long int r = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s = (s + a) % m;
        r += f[s];
        f[s]++;
    }

    cout << r << endl;
    
    return 0;
}