#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i, a[100005], s, b[100005], c = 1, d = 0;
  long long ans = 0;
  scanf("%d%d", &n, &m);
  a[0] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &s);
    a[i] = (a[i - 1] + s) % m;
  }
  sort(a, a + n + 1);
  a[n + 1] = 1000000005;
  for (i = 0; i <= n; i++) {
    if (a[i] == a[i + 1])
      c++;
    else {
      b[d] = c;
      c = 1;
      d++;
    }
  }
  for (i = 0; i < d; i++) {
    ans += b[i] * (b[i] - 1) / 2;
  }
  printf("%d", ans);
}
