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