#include <bits/stdc++.h>
using namespace std;
long long kai(long long k) {
  if (k == 0)
    return 1;
  else
    return k * kai(k - 1);
}
long long com(int a) {
  long long c;
  c = (kai(a) / kai(a - 2)) / 2;
  return c;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> V(n);
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      cin >> V[i];
    } else {
      cin >> V[i];
      V[i] += V[i - 1];
    }
    if (V[i] % m == 0) cnt++;
  }
  map<long long, long long> M;
  for (int i = 0; i < V.size(); i++) {
    M[V[i] % m]++;
  }
  for (auto v : M) {
    if (v.second >= 2) cnt += com(v.second);
  }
  cout << cnt << endl;
  return 0;
}
