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