#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> rui(n, 0);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if (i == 0)
      rui[i] = a;
    else
      rui[i] += rui[i - 1] + a;
  }
  for (int i = 0; i < n; i++) {
    rui[i] %= m;
  }
  sort((rui).begin(), (rui).end());
  for (int i = 0; i < n - 1; i++) {
    long long cnt = 1;
    while (i < n - 1 && rui[i] == rui[i + 1]) {
      cnt++;
      i++;
    }
    if (rui[i] == 0)
      ans += cnt * (cnt + 1) / 2;
    else
      ans += (cnt - 1) * cnt / 2;
  }
  cout << ans << endl;
  return 0;
}
