#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long a[100000];
long long rui[100001];
bool f[100001];
int main() {
  int n;
  long long m;
  long long ans = 0;
  cin >> n >> m;
  fill(rui, rui + 100001, 0);
  fill(f, f + 100001, false);
  for (int i = 0; i < n; i++) cin >> a[i];
  rui[0] = 0;
  for (int i = 1; i < n + 1; i++) rui[i] = rui[i - 1] + a[i - 1];
  if (rui[n] == m) {
    cout << 1 << endl;
    return 0;
  }
  if (rui[n] < m) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n + 1; i++) rui[i] %= m;
  for (int i = 0; i < n + 1; i++) {
    if (f[i]) continue;
    long long r = rui[i];
    long long cnt = 1;
    for (int j = i + 1; j < n + 1; j++) {
      if (r == rui[j]) {
        cnt++;
        f[j] = true;
      }
    }
    f[i] = true;
    if (cnt > 1) {
      ans += cnt * (cnt - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
