#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

typedef long long ll;

ll a[100005], kum[100005];
map <ll, ll> br;

int main ()
{
ll n, m;
cin >> n >> m;
for(int i = 1 ; i <= n ; ++i){
	cin >> a[i];
}
br[0] = 1;
ll sol = 0;
for(int i = 1 ; i <= n ; ++i){
	kum[i] = (kum[i - 1] + a[i]) % m;
	sol += br[kum[i]];
	br[kum[i]]++;
}
cout << sol;

return 0;
}