#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
template <typename T>
void vprint(T &v) {
  for (int i = 0; i < (int)v.size(); ++i) {
    cout << v[i] << " ";
  }
  cout << endl;
}
multiset<long long> ms;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < (int)N; ++i) cin >> A[i];
  vector<long long> Asum(N + 1);
  Asum[0] = 0;
  for (int i = 0; i < (int)N; ++i) Asum[i + 1] = Asum[i] + A[i];
  for (int i = 0; i < (int)N; ++i) A[i] %= M;
  for (int i = 0; i < (int)N + 1; ++i) Asum[i] %= M;
  ms.insert(0);
  long long res = 0;
  for (int i = 0; i < (int)N; ++i) {
    long long inv = (Asum[i + 1]) % M;
    res += ms.count(inv);
    ms.insert(Asum[i + 1]);
  }
  cout << res << endl;
  return 0;
}
