#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N), S(N + 1);
  S[0] = 0;
  map<long long, long long> map;
  map[0] = 1;
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    S[i + 1] = S[i] + A[i];
    if (map.count(S[i] % M)) {
      map[S[i] % M] += 1;
    } else {
      map[S[i] % M] = 1;
    }
  }
  for (auto key : map) {
    ans += key.second * (key.second - 1) / 2;
  }
  cout << ans << endl;
}
