#include <bits/stdc++.h>
typedef struct List {
  struct List *next;
  long long v;
  int num;
} list;
int main() {
  int i, N, M, A[100001];
  scanf("%d %d", &N, &M);
  for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
  list *h[10007] = {}, d[100001], *p;
  long long ans = 0, sum;
  d[0].v = 0;
  d[0].num = 1;
  d[0].next = NULL;
  h[0] = &(d[0]);
  for (i = 1, sum = 0; i <= N; i++) {
    sum = (sum + A[i]) % M;
    for (p = h[sum % 10007]; p != NULL; p = p->next)
      if (p->v == sum) break;
    if (p != NULL)
      p->num++;
    else {
      d[i].v = sum;
      d[i].num = 1;
      d[i].next = h[sum % 10007];
      h[sum % 10007] = &(d[i]);
    }
  }
  for (i = 0; i < 10007; i++) {
    for (p = h[i]; p != NULL; p = p->next) ans += p->num * (p->num - 1) / 2;
  }
  printf("%lld\n", ans);
  fflush(stdout);
  return 0;
}
