#include <bits/stdc++.h>
using namespace std;
bool comp_sec(pair<int, int> p, pair<int, int> q) {
  return p.second < q.second;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long a[n];
  a[-1] = 0;
  long long tmp;
  for (long i = 0; i < n; ++i) {
    cin >> tmp;
    if (i > 0) {
      a[i] = a[i - 1] + tmp;
    } else {
      a[i] = tmp;
    }
  }
  long long count = 0;
  for (long i = 0; i < n; ++i) {
    for (long j = -1; j < i; ++j) {
      if (j >= 0) {
        count += ((a[i] - a[j]) % m == 0);
      } else {
        count += ((a[i]) % m == 0);
      }
    }
  }
  cout << count << '\n';
  return 0;
}
