#include <cstdio>
#include <map>
using namespace std;

typedef long long ll;
ll n, m, a, k, ans;
map<ll, ll> mp={{0,1}};
int main() {
	scanf("%lld%lld", &n, &m);
	while(n--) {
		scanf("%lld", &a);
		k = (k+a) % m;
		ans += mp[k]++;
	}
	printf("%lld", ans);
	return 0;
}