#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> v(n);
  vector<long long> sum(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + v[i];
  }
  for (int i = 0; i <= n; i++) {
    sum[i] %= m;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (sum[j] == sum[i]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return (0);
}
