#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;
  vector<long long> x(m, 0);
  for (int i = 0; i < n; i++) x[a[i]]++;
  long long sum = x[0];
  for (int i = 0; i < m; i++) {
    sum += x[i] * (x[i] - 1) / 2;
  }
  cout << (sum) << endl;
  return 0;
}
