#include <bits/stdc++.h>
int compare(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int i, j, N, M, r, a[100001];
  long long v = 0;
  scanf("%d %d", &N, &M);
  a[0] = 0;
  for (i = 1; i <= N; i++) {
    scanf("%d", a + i);
    a[i] += a[i - 1];
    a[i] %= M;
  }
  qsort(a + 1, N, sizeof(int), compare);
  for (i = 0, j = 0; i <= N; i++) {
    if (a[i] != a[j]) {
      r = i - j;
      v += r * (r - 1) / 2;
      j = i;
    }
  }
  r = i - j;
  v += r * (r - 1) / 2;
  printf("%lld\n", v);
  return 0;
}
