#include <bits/stdc++.h>
using namespace std;
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int n;
int main(int argc, char const *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int m;
  cin >> n >> m;
  long long a[n];
  long long cumulative_sum[n];
  for (int i = (0); i < (n); ++i) cin >> a[i];
  long long count = 0;
  long long sum = 0;
  for (int i = (0); i < (n); ++i) {
    sum += a[i];
    cumulative_sum[i] = sum;
    if (sum % m == 0) count++;
  }
  long long tmp;
  for (int i = (0); i < (n); ++i) {
    for (int j = (i + 1); j < (n); ++j) {
      tmp = cumulative_sum[j] - cumulative_sum[i];
      if (tmp % m == 0) count++;
    }
  }
  cout << count << endl;
  return 0;
}
