#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>

typedef long long LL;
using namespace std;

map <LL, int> cnt;
int n, m;
int main() 
{
	scanf("%d%d", &n, &m);
	LL res = 0, ans = 0; cnt[0] = 1;
	for (int i = 1; i <= n; i++) {
		int x; scanf("%d", &x);
		ans = (ans + x) % m;
		res += cnt[ans];
		cnt[ans]++;
	}
	printf("%lld\n", res);
	return 0;
}
