#include <bits/stdc++.h>
int main(void) {
  long long n, m, k, i, a = 0, cou = 0, tmp = 0;
  scanf("%lld %lld", &n, &m);
  int *x;
  x = (int *)malloc(sizeof(int) * m);
  for (i = 0; i < m; i++) x[i] = 0;
  x[0]++;
  for (i = 0; i < n; i++) {
    scanf(" %lld", &tmp);
    a = (a + tmp) % m, x[a]++;
  }
  for (i = 0; i < m; i++) {
    cou += x[i] * (x[i] - 1);
  }
  printf("%lld", cou / 2);
}
