#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = static_cast<ll>(1e9) + 7;
const int MAXN = static_cast<int>(1e5) + 17;
int n, k;
int a[MAXN], s[MAXN];
bool read() {
  if (!(cin >> n >> k)) return false;
  for (ll i = 0; i < (ll)(n); ++i) cin >> a[i + 1];
  return true;
}
void solve() {
  for (ll i = 0; i < (ll)(n); ++i) s[i + 1] = (s[i] + a[i + 1]) % k;
  map<int, int> mp;
  ll ans = 0;
  mp[0] = 1;
  for (ll i = 0; i < (ll)(n); ++i) {
    ans += mp[s[i]];
    ++mp[s[i]];
  }
  cout << ans << '\n';
}
int main() {
  cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::mt19937 rand('S' + 'E' + 'R' + 'E' + 'Z' + 'H' + 'K' + 'A');
  while (read()) solve();
  return 0;
}
