#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> mp(M);
  mp[0] = 1;
  long long n = 0;
  while (N--) {
    long long a;
    cin >> a;
    n = (n + a) % M;
    mp[n]++;
  }
  long long ans = 0;
  for (long long i = 0; i < M; i++) ans += mp[i] * (mp[i] - 1) / 2;
  cout << ans << endl;
}
