#include<cstdio>
#include<map>

using namespace std;

const int N = 100005;

int n, m, a[N];
map<int, int> c;
long long ans;

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