#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll a[100001];
ll b[100001];
map<ll, ll> mp;
int main() {
  ll n, m;
  scanf("%lld%lld", &n, &m);
  for (ll i = 0; i < (ll)(n); i++) {
    scanf("%lld", &a[i]);
  }
  for (ll i = 1; i <= (ll)(n); i++) {
    b[i] = b[i - 1] + a[i - 1];
  }
  mp[0] = 1;
  for (ll i = 1; i <= (ll)(n); i++) {
    if (b[i] >= m) mp[b[i] % m]++;
  }
  ll sum = 0;
  for (auto at : mp) {
    sum += at.second * (at.second - 1) / 2;
  }
  cout << sum << endl;
}
