#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll> a(n);
  vector<ll> sum(n);
  for(int i = 0;i < n;i++){
    ll A;
    cin >> A;
    A %= m;
    a[i] = A;
    if(i == 0)sum[i] = a[i];
    else sum[i] = sum[i-1]+a[i];
    sum[i] %= M;
  }
  sort(sum.begin(),sum.end());
  ll count = 1;
  ll ans = 0;
  for(int i = 0;i < n-1;i++){
    if(s[i] == s[i+1])count++;
    else{
      ans += count*(count-1)/2;
      count = 1;
    }
  }
  ans += count*(count-1)/2;
  cout << ans << endl;
}
    
    
  