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