import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto data = readln.split, N = data[0].to!long, M = data[1].to!long;
	auto A = readln.split.to!(long[]);
	
	long sum = 0;
	long[long] hash; hash[0] = 1;
	foreach (i; 0 .. N) {
		sum += A[i] % M;
		if (sum >= M) sum -= M; 
		if (sum !in hash) hash[sum] = 1;
		else hash[sum]++;
	}
	
	ulong ans;
	foreach (n; hash.byValue) {
		ans += n*(n-1)/2;
	}
	writeln(ans);
}