#include <bits/stdc++.h>
using namespace std;
int N, M, A[100001];
unsigned long long num_of_pair = 0;
unsigned long long combination(int n, int r) {
  if (n == r || r == 0) {
    return 1;
  }
  return combination(n - 1, r - 1) + combination(n - 1, r);
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  for (int i = 0; i < N; ++i) {
    if (i == 0) {
      A[i] = A[i] % M;
    }
    A[i + 1] = (A[i + 1] + A[i]) % M;
  }
  for (int i = 0; i < M; ++i) {
    long cnt;
    if ((cnt = count(A, A + N, i)) >= 1 && i == 0) {
      num_of_pair += cnt;
    }
    if (cnt >= 2) {
      num_of_pair += combination(cnt, 2);
    }
  }
  cout << num_of_pair << endl;
  return 0;
}
