#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long M;
  cin >> N >> M;
  vector<long long> A(N);
  vector<long long> sum(N + 1, 0);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum[i + 1] = sum[i] + A[i];
  }
  set<long long> S;
  map<long long, int> C;
  for (auto &s : sum) {
    s %= M;
    S.insert(s);
    C[s]++;
  }
  long long ans = 0;
  for (auto s : S) ans += C[s] * (C[s] - 1) / 2;
  cout << ans << endl;
  return 0;
}
