#include <bits/stdc++.h>
int main() {
  int n, m;
  int *map;
  int i, j;
  int input, sum;
  long long int res, temp;
  scanf("%d %d", &n, &m);
  map = (int *)malloc(sizeof(int) * 2 * n + 2);
  for (i = 0; i < n + 1; i++) map[2 * i] = -1;
  map[0] = 0;
  map[1] = 1;
  sum = 0;
  res = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &input);
    sum += input;
    sum %= m;
    for (j = 0; j < n; j++) {
      if (map[j * 2] == sum) {
        map[j * 2 + 1] += 1;
        break;
      }
      if (map[j * 2] == -1) {
        map[j * 2] = (sum % m);
        map[j * 2 + 1] = 1;
        break;
      }
    }
  }
  for (i = 0; i < n; i++) {
    if (map[i * 2] == -1) break;
    temp = map[i * 2 + 1];
    res += temp * (temp - 1) / 2;
  }
  printf("%d\n", res);
  free(map);
  return 0;
}
