#include <bits/stdc++.h>
using namespace std;
int inf = 1000000000;
template <typename T>
T GCD(T a, T b) {
  while (max(a, b) % min(a, b)) {
    if (a > b)
      a = a % b;
    else
      b = b % a;
  }
  return min(a, b);
}
template <typename T>
T LCM(T a, T b) {
  return a / GCD(a, b) * b;
}
long long ruiseki[100010], ruiseki2[100010];
int main() {
  long long n, m, ans = 0;
  cin >> n >> m >> ruiseki[0];
  ruiseki[0] %= m;
  ruiseki2[0] = ruiseki[0];
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    ruiseki[i] = a + ruiseki[i - 1];
    ruiseki[i] %= m;
    ruiseki2[i] = ruiseki[i];
  }
  sort(ruiseki, ruiseki + n);
  for (int i = 0; i < n; i++) {
    long long f = upper_bound(ruiseki, ruiseki + n, ruiseki[i]) -
                  lower_bound(ruiseki, ruiseki + n, ruiseki[i]);
    ans += max((f * (f - 1)) / 2, (long long)0);
    while (ruiseki[i] == ruiseki[i - 1]) {
      i++;
      if (i == n) break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (ruiseki[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}
