#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long N, M;
  cin >> N >> M;
  vector<long> A(N);
  map<int, int> mp;
  int mod;
  mod = 0;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    mod = (mod + A[i]) % M;
    if (mod == 0) {
      mp[mod]++;
    }
    ans += mp[mod];
    mp[mod]++;
  }
  cout << ans << "\n";
  return 0;
}
