#include <bits/stdc++.h>
const int MOD = 1000000007, INF = 1111111111;
using namespace std;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) A[i] %= M;
  for (int i = 0; i < N - 1; i++) {
    A[i + 1] += A[i];
    A[i + 1] %= M;
  }
  vector<int> mod(M);
  for (int i = 0; i < N; i++) mod[A[i] % M]++;
  long long ans = mod[0] * (mod[0] + 1) / 2;
  for (int i = 1; i < M; i++) ans += mod[i] * (mod[i] - 1) / 2;
  cout << ans << "\n";
  return 0;
}
