#include <bits/stdc++.h>
using namespace std;
template <typename T>
T id(T b) {
  return b;
};
template <class It>
bool all(It f, It l) {
  return std::all_of(f, l, id<bool>);
}
template <class It>
bool any(It f, It l) {
  return std::any_of(f, l, id<bool>);
}
const int MAX_N = 100000;
int n;
long long m;
long long a[MAX_N];
long long psum[MAX_N + 1];
map<long long, int> cnt;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  psum[0] = 0;
  cnt[psum[0] % m]++;
  for (int i = 0; i < n; ++i) {
    psum[i + 1] = psum[i] + a[i];
    cnt[psum[i + 1] % m]++;
  }
  long long res = 0;
  for (auto p : cnt) {
    res += p.second * (p.second - 1) / 2;
  }
  cout << res << endl;
  return 0;
}
