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