#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    A[i] %= M;
  }
  vector<long long> ac(N + 1);
  ac[0] = 0;
  for (int i = 0; i < N; ++i) {
    ac[i + 1] = (ac[i] + A[i]) % M;
  }
  map<long long, int> m;
  for (int i = 0; i < ac.size(); ++i) {
    m[ac[i]]++;
  }
  long long ans = 0;
  for (auto it = m.begin(); it != m.end(); ++it) {
    ans += it->second * (it->second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
