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