#include <bits/stdc++.h>
int compare(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int n, m, a, sum[111111];
  scanf("%d%d", &n, &m);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    if (i == 0)
      sum[0] = a;
    else {
      sum[i] = sum[i - 1] + a;
      if (sum[i] >= m) sum[i] -= m;
    }
  }
  qsort(sum, n, sizeof(int), compare);
  long count = 1, memory = sum[0], ans = 0;
  for (i = 1; i < n; i++) {
    if (sum[i] != memory) {
      ans += count * (count - 1) / 2;
      count = 1;
      memory = sum[i];
    } else
      count++;
  }
  ans += count * (count - 1) / 2;
  printf("%ld\n", ans);
  return 0;
}
