#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;
}
int const INF = 1 << 30;
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<long long> sa(n + 1);
  map<long long, int> mp;
  for (int i = 0; i < (n); ++i) sa[i + 1] = sa[i] + a[i];
  for (int i = 0; i < (n + 1); ++i) {
    mp[sa[i] % m]++;
  }
  long long res = 0;
  for (auto [s, t] : mp) res += t * (t - 1) / 2;
  cout << res << endl;
  return 0;
}
