#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> A(N), G(N + 1);
  map<int, int> amari;
  for (int i = 0; i < (N); ++i) {
    cin >> A[i];
    G[i + 1] = G[i] + A[i];
    amari[G[i + 1] % M]++;
  }
  amari[0]++;
  long long ans = 0;
  for (int i = 0; i < (N + 1); ++i) {
    if (amari[G[i] % M] > 0) {
      ans += amari[G[i] % M] * (amari[G[i] % M] - 1) / 2;
      amari[G[i] % M] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
