#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, m;
  vector<int> a;
  int ans = 0;
  cin >> n >> m;
  a.reserve(n);
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    a.push_back(t % m);
  }
  vector<int> sum;
  int acc = 0;
  sum.reserve(n + 1);
  sum.push_back(0);
  for (int i = 0; i < n; i++) {
    acc += a[i];
    acc %= m;
    sum.push_back(acc);
  }
  for (int s = 0; s < n; s++) {
    for (int e = s; e < n; e++) {
      if (sum[e + 1] == sum[s]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
