#pragma region 입출력 속도향상
#define FAST_IO() \
{\
ios::sync_with_stdio(false);\
cin.tie(NULL); \
cout.tie(NULL); \
}\
#pragma endregion
#include <iostream>
#include <vector>
using namespace std;
int main()
{
FAST_IO();
int n, m;
cin >> n >> m;
vector<long> v(n + 1), c(m);
vector<long> s(n + 1);
long ans = 0;
for (int i = 1; i <= n; i++)
{
int tmp;
cin >> tmp;
v[i] = (v[i - 1] + tmp) % m;
ans += (v[i] == 0);
c[v[i]]++;
}
for (const auto& val : c)
ans += (val * (val - 1) / 2);
cout << ans;
return 0;
}