#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  vector<long long> A, b;
  cin >> N >> M;
  long long s = 0;
  for (int i = 0, a; i < N; ++i) {
    cin >> a;
    A.push_back(a);
    b.push_back(s += a);
  }
  int c = 0;
  for (int l = 0; l < N; ++l) {
    c += count_if(b.begin(), b.end(),
                  [M](long long x) { return x >= 0 && x % M == 0; });
    vector<long long> t = b;
    transform(b.begin(), b.end(), t.begin(), [A, l](long long x) {
      long long t = x - A[l];
      return t > 0 ? t : -1;
    });
    b = t;
  }
  cout << c << endl;
  return 0;
}
