#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 1;
ll arr[N], sum[N];
int main() {
  ios_base::sync_with_stdio();
  cin.tie(0);
  cout.tie(0);
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%lld", arr + i);
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + arr[i];
    sum[i + 1] %= m;
  }
  map<ll, ll> freq;
  for (int i = 0; i < n; ++i) {
    ++freq[sum[i]];
  }
  ll ans = 0;
  for (auto i : freq) {
    ans += i.second * (i.second - 1) / 2;
    if (i.first == 0) ans += i.second;
  }
  cout << ans;
}
