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