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