#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> A(n);
  vector<long long> V(n + 1);
  for (int i = 0; i < A.size(); i++) {
    cin >> A[i];
  }
  V[0] = 0;
  for (int i = 0; i < A.size(); i++) {
    V[i + 1] = (A[i] + V[i]) % m;
  }
  long long cnt = 0;
  map<long long, long long> M;
  for (int i = 0; i < V.size(); i++) {
    cnt += M[V[i]];
    V[i]++;
  }
  cout << cnt << endl;
  return 0;
}
