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