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