#include <bits/stdc++.h>
using namespace std;
int main() {
  long N, M;
  cin >> N >> M;
  vector<long> A(N);
  for (long i = 0; i < N; i++) cin >> A[i];
  vector<long> C(M, 0);
  long s = 0;
  long ans = 0;
  for (long i = 0; i < N; i++) {
    s = (s + A[i]) % M;
    ans += C[s];
    C[s]++;
    if (s == 0) ans++;
  }
  cout << ans;
}
