#include <bits/stdc++.h>
using namespace std;
int sum[1000000];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    int x;
    sum[0] = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      sum[i] = (sum[i - 1] + x) % m;
    }
    sort(sum, sum + n + 1);
    int s = 1;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      if (sum[i] == sum[i - 1])
        s++;
      else {
        ans += s * (s - 1) / 2;
        s = 1;
      }
    }
    ans += s * (s - 1) / 2;
    printf("%lld\n", ans);
  }
  return 0;
}
