#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, m;
  scanf("%lld%lld", &n, &m);
  ll a[100000];
  for (int i = 0; i < n; i++) scanf("%lld", a + i);
  ll sum[100008];
  sum[0] = 0;
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i - 1];
  ll rem[100008];
  for (int i = 0; i <= n; i++) rem[i] = sum[i] % m;
  map<ll, ll> rem_cnt[100008];
  rem_cnt[n][rem[n]] = 1;
  for (int i = n - 1; i >= 0; i--) {
    rem_cnt[i] = rem_cnt[i + 1];
    if (rem_cnt[i].find(rem[i]) != rem_cnt[i].end()) {
      rem_cnt[i][rem[i]]++;
    } else {
      rem_cnt[i][rem[i]] = 1;
    }
  }
  ll ans = 0;
  for (map<ll, ll>::iterator it = rem_cnt[0].begin(); it != rem_cnt[0].end();
       ++it) {
    if (it->second >= 2) {
      ans += (it->second - 1) * (it->second) / 2;
    }
  }
  printf("%lld\n", ans);
}
