#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, A[100000];
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> A[i];
  long long B[100000];
  B[0] = 0;
  for (int i = 0; i < n; i++) B[i + 1] = B[i] + A[i];
  for (int i = 1; i <= n; i++) B[i] = B[i] % m;
  long long ans;
  for (int i = 1; i <= n; i++) {
    if (B[i] == 0) ans++;
  }
  sort(B + 1, B + n + 1);
  int ptr = 1;
  long cc;
  while (ptr < n + 1) {
    cc = B[ptr];
    int e = 0;
    while (ptr < n + 1 && B[ptr] == cc) e++, ptr++;
    ans += e * (e - 1) / 2;
  }
  cout << ans;
}
