#include<iostream>
#include<map>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;

int main(){
    int n,k;
    cin>>n>>k;
    ll ans=0;
    map<int,int> mp;
    ll sum=0;
    mp[0]++;
    rep(i,n){
        int x;cin>>x;
        (sum+=x)%=k;
        ans+=mp[sum]++;
    }
    cout<<ans<<endl;
}