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