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