#include <iostream>
#include <vector>
#include <map>
using namespace std;

typedef long long ll;

int main()
{
  int N, M;
  cin >> N >> M;

  map<ll, ll> nums;
  ll sum = 0;

  nums[sum]++;
  for(int i = 0; i < N; i++){
    ll a;
    cin >> a;
    sum += a;
    nums[sum % M]++;
  }

  ll ans = 0;
  for(auto i : nums){
    ans += i.second * (i.second-1) / 2;
  }

  cout << ans << endl;

  return 0;
}