#include <bits/stdc++.h>
int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int a[n + 1];
  a[n] = 0;
  scanf("%d", &a[0]);
  a[0] = a[0] % m;
  for (int i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] = (a[i] + a[i - 1]) % m;
  }
  std::sort(a, a + n + 1);
  long long ans = 0;
  int x = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a[i] != a[i - 1] || i == n) {
      if (a[i] == a[i - 1]) x++;
      ans += x * (x + 1) / 2;
      x = 0;
    } else
      x++;
  }
  printf("%lld\n", ans);
}
