#include <bits/stdc++.h>
int main(void) {
  int n, m, a[100001];
  long b[100001];
  int mod[100001] = {0};
  int mod_num = 0;
  int count[100001] = {0};
  long sum;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  b[0] = 0;
  for (int i = 1; i <= n; i++) b[i] = b[i - 1] + a[i];
  for (int i = 0; i <= n; i++) {
    int rem = b[i] % m;
    int idx = -1;
    for (int j = 0; j < mod_num; j++)
      if (mod[j] == rem) {
        idx = j;
        break;
      }
    if (idx == -1) {
      mod[mod_num] = rem;
      idx = mod_num;
      mod_num++;
    }
    count[idx]++;
  }
  sum = 0;
  for (int i = 0; i < mod_num; i++) sum += (count[i] - 1) * count[i] / 2;
  printf("%ld\n", sum);
  return 0;
}
