#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int sum[100005];
map<int, int> dp;
int main(){
	int n, m, a;
	scanf("%d%d", &n, &m);
	LL ans = 0;

	int tmp = 0;
	dp[0] = 1;
	for(int i=1;i<=n;i++){
		scanf("%d", &a);
		tmp += a;
		tmp %= m;
		ans += dp[tmp];
		dp[tmp]++;
	}
	printf("%lld\n", ans);
}