#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= m;
  }
  vector<int> accum(n + 1, 0);
  for (int i = 1; i <= n; i++) {
    accum[i] = (accum[i - 1] + a[i - 1]) % m;
  }
  map<int, int> dat;
  for (int i = 0; i <= n; i++) {
    dat[accum[i]]++;
  }
  long long ans = 0;
  for (auto t : dat) {
    ans += t.second * (t.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
