#include <iostream>
using namespace std;
int dp[1000000001] = {};

int main() {
	int n;
	int mod;
	cin >> n >> mod;
	dp[0] = 1;
	int a = 0;
	int s = 0;
	for (int i(0); i < n; ++i) {
		int b;
		cin >> b;
		a += b;
		a %= mod;
		s += dp[a];
		++dp[a];
	}
	cout << s << endl;
}
