#include <bits/stdc++.h>
int comp(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main(int argc, const char *argv[]) {
  int n, m, a[100010];
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int sum[100010];
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = (sum[i - 1] + a[i - 1]) % m;
  }
  qsort(sum, n + 1, sizeof(int), comp);
  int k = 0;
  long long cnt, ans = 0;
  while (k <= n) {
    cnt = 0;
    while (sum[k] == sum[k + 1]) {
      k++;
      cnt++;
    }
    cnt++;
    k++;
    ans += cnt * (cnt - 1) / (long long)2;
  }
  printf("%lld\n", ans);
  return 0;
}
