#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long ncr(long long n, long long r) {
  long long v[n + 1][n + 1];
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i) {
        v[i][j] = 1;
      } else {
        v[i][j] = v[i - 1][j - 1] + v[i - 1][j];
      }
    }
  }
  return v[n][r];
}
long long N, M, ans, cnt, now;
int main() {
  cin >> N >> M;
  long long A[N];
  for (int i = 0; i < (int)(N); i++) {
    cin >> A[i];
    A[i] = A[i] % M;
  }
  for (int i = 0; i < (int)(N - 1); i++) {
    A[i + 1] = (A[i + 1] + A[i]) % M;
  }
  sort(A, A + N);
  now = 0;
  cnt = 1;
  for (int i = 0; i < (int)(N); i++) {
    if (now == A[i]) {
      cnt++;
    } else {
      if (cnt > 1) ans += ncr(cnt, 2);
      cnt = 1;
      now = A[i];
    }
  }
  ans += ncr(cnt, 2);
  cout << ans << endl;
}
