#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N + 1, 0);
  for (ll i = 0; i < N; ++i)
  {
    ll a;
    cin >> a;
    A.at(i + 1) = (A.at(i) + a) % M;
  }
  sort(A.begin(), A.end());
  ll cnt = 0;
  before = -1;
  ll ans = 0;
  for (ll i = 0; i < N; ++i)
  {
    if (A.at(i) == before)
    {
      cnt += 1;
    }
    else
    {
      ans += (cnt - 1) * cnt / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1);
  cout << ans << endl;
}
