#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> vec(M, 0);
  long long S = 0;
  long long tmp;
  for (long long i = 0; i < N; ++i) {
    cin >> tmp;
    tmp = tmp % M;
    S = (S + tmp) % M;
    vec[S]++;
  }
  long long ans = vec[0];
  for (long long i = 0; i < M; ++i) {
    long long n = vec[i];
    ans += n * (n - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
