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