#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long sum[n];
  int a;
  map<long long, int> r;
  r[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (i)
      sum[i] = (sum[i - 1] + a) % m;
    else
      sum[0] = a;
    auto itr = r.find(sum[i] % m);
    if (itr == r.end())
      r[sum[i] % m] = 1;
    else
      r[sum[i] % m]++;
  }
  int ans = 0;
  for (auto itr = r.begin(); itr != r.end(); itr++) {
    int num = itr->second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
