#include <bits/stdc++.h>
using namespace std;
long long int sum[100010];
map<long long int, long long int> Q;
int main() {
  long long int n, m;
  while (scanf("%I64d%I64d", &n, &m) != EOF) {
    Q.clear();
    sum[0] = 0;
    long long int ans = 0;
    for (long long int i = 1; i <= n; i++) {
      scanf("%I64d", &sum[i]), sum[i] += sum[i - 1], sum[i] %= m;
      Q[sum[i]]++;
    }
    Q[0]++;
    map<long long int, long long int>::iterator it = Q.begin();
    while (it != Q.end()) {
      ans += (it->second) * (it->second - 1) / 2;
      it++;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
