#include<bits/stdc++.h>
using namespace std;
#define int long long 

int sum = 0,ans = 0;
map<int,int> mp;

signed main(){

  int n,m; cin >> n >> m;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    sum += a;
    mp[sum%m]++;
    if(sum%m == 0) ans++;
  }

  for(auto p = mp.begin(); p != mp.end(); p++){
    ans += (p->second-1) * p->second / 2; // nC2
  }
  cout << ans << endl;

  return 0;
}
