#include <bits/stdc++.h>
int cmpAsc(const void* a, const void* b) {
  int x = *(int*)a, y = *(int*)b;
  if (x > y) {
    return 1;
  }
  if (x < y) {
    return -1;
  }
  return 0;
}
int main() {
  int n;
  long long int m;
  scanf("%d %lld", &n, &m);
  long long int a[n + 1];
  a[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    scanf("%lld", &a[i]);
  }
  for (int i = 1; i < n + 1; i++) {
    a[i] += a[i - 1];
    a[i] %= m;
  }
  qsort(a, n + 1, sizeof(long long int), cmpAsc);
  int cnt = 1, target = -1;
  long long int ans = 0;
  for (int i = 0; i < n + 1; i++) {
    if (a[i] == target) {
      ans += (long long int)cnt;
      cnt++;
    } else {
      target = a[i];
      cnt = 1;
    }
  }
  printf("%lld", ans);
  return 0;
}
