#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  vector<ll> csum{0};
  partial_sum(va.begin(), va.end(), back_inserter(csum));
  map<ll, ll> cnts;
  for (auto s : csum) {
    cnts[s % m]++;
  }

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

  cout << ans << '\n';
  return 0;
}
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;
const double PI = 3.14159265358979323846264338327950288;

ll A[100010];
ll sum[100010];
int main()
{
	int N;
	ll M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 0;
	map<ll, ll> mp;
	for (int i = 0; i < N; i++) {
		sum[i + 1] = (sum[i] + A[i]) % M;
	}
	sort(sum, sum + N + 1);
	ll cnt = 1;
	for (int i = 0; i < N; i++) {
		if (sum[i] == sum[i + 1]) {
			cnt++;
		}
		else {			
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt * (cnt - 1) / 2;
	cout << ans << endl;
}
