#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define MAXN 4000007
#define mo 19930726
using namespace std;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll a[MAXN],sum[MAXN],n,m,ans;
map<ll,ll> mp;
int main()
{
	cin>>n>>m;
	for(re int i=1;i<=n;i++){
		cin>>a[i];
		sum[i]=(sum[i-1]+a[i])%m;
	}
	for(re int i=1;i<=n+1;i++){
		ans+=mp[sum[i]];
		mp[sum[i]]++;
	}
	cout<<ans;
}