#include <bits/stdc++.h>
void printer(int *a, int size) {
  int i;
  for (i = 0; i < size; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
  return;
}
int main(void) {
  long long counter;
  int i, N, M, val, sum = 0;
  scanf("%d %d", &N, &M);
  int *a;
  a = (int *)malloc(M * sizeof(int));
  for (i = 0; i < M; i++) {
    a[i] = 0;
  }
  for (i = 0; i < N; i++) {
    scanf("%d", &val);
    a[(sum + val) % M]++;
    sum = (sum + val) % M;
  };
  counter = a[0];
  for (i = 0; i < M; i++) {
    if (a[i] != 0) {
      counter += (a[i] * (a[i] - 1)) / 2;
    }
  }
  printf("%lld\n", counter);
  return 0;
}
