#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  map<ll,ll> mp;
  mp[0]++;
  ll sum = 0;
  rep(i,n) {
    sum += a[i];
    mp[sum % m]++;
  }
  ll res = 0;
  for (auto &e : mp) res += e * (e - 1)/2;
  cout << res << endl;
  return 0;
} 