#include <bits/stdc++.h>
using ll = unsigned long long;
using namespace std;
int main() {
  ll n, x, m, cnt = 0;
  cin >> n >> m;
  vector<ll> a(n), mod(n);
  a[0] = mod[0] = 0;
  for (ll i = 1; i <= n; i++) {
    cin >> x;
    a[i] = a[i - 1] + x;
    mod[i] = a[i] % m;
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = i + 1; j <= n; j++) {
      if (mod[i] == mod[j]) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
