#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

typedef long long ll;
typedef pair<string, int> P;

#define int long long
const int N = 1e5 + 9;
int x, n, m, s, ans;
map<int, int> mp;
int main(){
	scanf("%lld%lld", &n, &m);
	for (int i = 1; i <= n; i++)
	{
		scanf("%lld", &x);
		x %= m;
		s += x;
		s %= m;
		ans += mp[s];
		mp[s]++;
		if (!s)
			ans++;
	}
	cout << ans << endl;
}