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

const int lens = 1e5 + 1;
long long n,m,a[lens],sum[lens];
std::map<long long,long long> map;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin >> n >> m;
    for(int i = 1;i <= n;i++)
    {
        std::cin >> a[i];
    }   

    long long ans = 0;
    map[0]++; 
    for(int i = 1;i <= n;i++)
    {
        sum[i] = (sum[i - 1] + a[i]) % m;
        ans += map[sum[i]];
        map[sum[i]]++;
    }
    std::cout << ans;
    return 0;
}
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	ll n, m;
	cin >> n >> m;

	vector<ll> a(n);
	rep(i, n) cin >> a[i];

	map<ll, ll> mp;
	ll sum = 0;
	mp[sum]++;

	for (int i = 0; i < n; i++) {
		sum += a[i];
		mp[sum % m]++;
	}

	ll ans = 0;
	for (auto m : mp) {
		ans += m.second * (m.second - 1) / 2;
	}

	out(ans);

	return 0;
}