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 s;
	foreach (i; 1 .. N+1) { s += A[i-1]; s %= M; sum ~= s; }
	
	//writeln(sum);
	
	auto mod = sum.sort();
	ulong ans;
	foreach (x; mod.group()) {
		ans += x[1]*(x[1]-1)/2;
	}
	writeln(ans);
}