#include <bits/stdc++.h>
int mod[100001];
long count[100001];
int binsearch(int rem) {
  int idx = 0;
  while (mod[idx] != -1)
    if (rem < mod[idx])
      idx = 2 * idx + 1;
    else if (rem > mod[idx])
      idx = 2 * idx + 2;
    else
      break;
  return idx;
}
int main(void) {
  int n, m, a[100001];
  long b[100001];
  long sum;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < 100001; i++) mod[i] = -1;
  b[0] = 0;
  for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i];
  for (int i = 0; i <= n; i++) {
    int rem = b[i] % m;
    int idx = binsearch(rem);
    if (mod[idx] == -1) {
      mod[idx] = rem;
    }
    count[idx]++;
  }
  sum = 0;
  for (int i = 0; i < 100001; i++) sum += (count[i] - 1) * count[i] / 2;
  printf("%ld\n", sum);
  return 0;
}
