#include<iostream>//基本
#include<algorithm>//min,maxとか
#include<vector>//配列
#include<string>//文字化
#include<cmath>//
#include<map>//map<int,int>toka
#include<iomanip>//
#include<numeric>//
#include<queue>//
#include<functional>//
#include<tuple>//
#include<intrin.h>
#include<math.h>
#include<bitset>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define sec setprecision　//小数点以下何位まで知りたいか
#define mod 1000000007
#define pi 3.14159265
using namespace std;
int gcd(int a, int b)//最大公約数
{if (a % b == 0)	return(b);
	else return(gcd(b, a % b));}
int lcm(int a, int b)//最小公倍数
{return a * b / gcd(a, b);}
ll pow(ll a, ll b) {ll k = b % 30000, h = b / 30000, s = 1;
	rip(i, 30000)s = (s * a) % mod; ll j = 1;
	if (h != 0)rip(i, h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);}
int main() {
	int n; ll m;
	cin >> n >> m;
	vector<ll>a(n);
	rip(i, n)cin >> a[i], a[i] = a[i] % m;
	ll sum[100010];//dp[i]haa[i]madenowano%m
	sum[0] = 0;
	ll summ = 0;
	rip(i, n) {
		summ += a[i];
		summ = summ % m;
		sum[i+1] = summ;
	}
	map<ll,int> b;
	for (int i =0; i <= n; i++) {
		b[sum[i]] += 1;
	}
	int count = 0;
	for(int i=0;i<m;i++){
		count += b[i] * (b[i] - 1) / 2;
	}
	cout << count << endl;
}