# include "iostream"
# include "cstdio"
# include "map"

using namespace std;

int n,m; 
long long sum,ans;
map<int,int> L;
 
int main(){
	register int i; 
	int x; 
	scanf("%d%d",&n,&m); 
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		sum=(sum+x)%m;
		ans+=L[sum];
		L[sum]++; 
	}
	printf("%lld",ans+L[0]); 
	return 0; 
} 