#include <bits/stdc++.h>
using namespace std;
int main() {
  long long Count = 0;
  int N, M;
  cin >> N >> M;
  vector<vector<int>> Sums;
  Sums.resize(N);
  for (int i = 0; i < N; i++) {
    Sums[i].resize(N);
  }
  int n;
  for (int i = 0; i < N; i++) {
    cin >> n;
    if (i == 0) {
      n %= M;
    } else {
      n = (n + Sums[0][i - 1]) % M;
    }
    Sums[0][i] = n;
    if (Sums[0][i] == 0) Count++;
  }
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N; j++) {
      Sums[i][j] = Sums[i - 1][j] - Sums[0][i - 1];
      if (Sums[i][j] == 0) Count++;
    }
  }
  cout << Count << endl;
}
