#include <bits/stdc++.h>
int compare(const void *a, const void *b) {
  long long diff = *(long long *)a - *(long long *)b;
  return diff < 0 ? -1 : (diff > 0 ? 1 : 0);
}
int main() {
  int i, j, N, M, r;
  long long a[100001], v = 0;
  scanf("%d %d", &N, &M);
  a[0] = 0;
  for (i = 1; i <= N; i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
    a[i] %= M;
  }
  qsort(a + 1, N, sizeof(long long), compare);
  for (i = 1, 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;
}
