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