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