#include <bits/stdc++.h>
void quicksort(long int a[], int s, int t) {
  if (s < t) {
    long int i = s, j = t, p = a[(s + t) / 2];
    while (1) {
      while (a[i] < p) i++;
      while (p < a[j]) j--;
      if (i >= j) break;
      a[i] ^= a[j] ^= a[i] ^= a[j];
      i++;
      j--;
    }
    quicksort(a, s, i - 1);
    quicksort(a, j + 1, t);
  }
}
int main() {
  long int a[100001] = {}, n, m, i, j, x = 0;
  scanf("%ld%ld", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%ld", &a[i]);
    a[i] = (a[i - 1] + a[i]) % m;
  }
  quicksort(a, 0, n);
  i = 0;
  while (i <= n) {
    while (a[i] == a[j] && j <= n) j++;
    x += (j - i) * (j - i - 1) / 2;
    i = j;
  }
  printf("%ld", x);
}
