#include <iostream>
#include <map>

using namespace std;

int main()
{
    int N, M;
    cin>>N>>M;
    map<int, int> C;
    long long ans = 0;
    int S = 0;
    for (int i=0; i<N; i++)
    {
        int A;
        cin>>A;
        S = (S+A)%M;
        C[((A-S)%M+M)%M]++;
        ans += C[(M-S)%M];
    }
    cout<<ans<<endl;
}
