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