#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  B[0] = 0;
  for (int i = 1; i <= N; i++) {
    B[i] = (B[i - 1] + A[i - 1]) % M;
  }
  sort(B.begin(), B.end());
  long long ans = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (B[i] == B[j]) {
        ans++;
      }
      if (B[i] < B[j]) {
        break;
      }
    }
  }
  cout << ans << endl;
}
