#include <bits/stdc++.h>
int main(void) {
  int N, r[1000005] = {}, i, j;
  long M, a[100005], n[100005], count, m;
  char str[1100000], *p;
  fgets(str, sizeof(str), stdin);
  p = strtok(str, " \n");
  N = atoi(p);
  p = strtok(NULL, " \n");
  M = atol(p);
  a[0] = 0;
  n[0] = 0;
  r[0]++;
  fgets(str, sizeof(str), stdin);
  p = strtok(str, " \n");
  a[1] = atol(p);
  n[1] = a[1];
  r[n[1] % M]++;
  for (i = 2; i < N + 1; i++) {
    p = strtok(NULL, " \n");
    a[i] = atol(p);
    n[i] = n[i - 1] + a[i];
    r[n[i] % M]++;
  }
  for (i = 1, count = 0; i < N + 1; i++) {
    m = n[i] % M;
    if (r[m] > 1) {
      count += r[m] * (r[m] - 1) / 2;
      r[m] = 0;
    }
  }
  printf("%ld\n", count);
  return 0;
}
