#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s) freopen((string(s) + ".inp").c_str(), "r", stdin),\
		freopen((string(s) + ".out").c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 1e5 + 5, LIM = 1e6 + 5;
int n, m, a[N];
map<int, int> cnt;
signed main() {
	#ifdef BLU
	//in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	fw (i, 0, n) cin >> a[i];
	memset(cnt, 0, sizeof cnt);
	cnt[0]++;
	int sum = 0, ans = 0;
	fw (i, 0, n) {
		sum += a[i];
		sum %= m;
		ans += cnt[sum];
		cnt[sum]++;
	}
	cout << ans;
	return 0;
}