#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline T GCD(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <class T>
inline T LCM(T a, T b) {
  return a / GCD(a, b) * b;
}
int main() {
  long long n, m, a[100010];
  long long ans = 0;
  cin >> n >> m;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
  }
  long long sum = 0;
  map<int, int> v;
  v[0] = 1;
  for (int i = 0; i < (n); i++) {
    sum += a[i];
    v[sum % m]++;
  }
  for (auto itr = v.begin(); itr != v.end(); itr++) {
    ans += (itr->second) * (itr->second - 1) / 2;
  }
  cout << ans << endl;
}
