#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (long long i = ((long long)0); i < ((long long)N); i++) cin >> A[i];
  vector<long long> s(N + 1);
  for (long long i = ((long long)0); i < ((long long)N); i++)
    s[i + 1] += (s[i] + A[i]) % M;
  sort(s.begin(), s.end());
  long long ans = 0;
  for (long long i = 0; i < s.size();) {
    long long j = i;
    while (s[i] == s[j]) j++;
    long long d = j - i;
    ans += d * (d - 1) / 2;
    i = j;
  }
  cout << ans << endl;
}
