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