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