// coding on smartphone
#include<iostream>
#include<map>
using namespace std;

typedef long long ll;

int main(){
  int n, m, a;
  ll ans = 0;
  map<int,ll> appear;
  
  cin >> n >> m;
  ll a[n+1];
  a[0] = 0;
  
  for(int i = 1; i <= n; i++){
    cin >> a[i];
    a[i] += a[i-1];
    appear[a[i]%m]++;
  }
  
  for(pair<int,int> x : appear)
    ans += ll(x.second) * (x.second - 1) / 2 + (x.first == 0 ? n : 0);
  
  cout << ans << endl;
  
  return 0;
}
