#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

ll modpow(ll x, ll p){
    if(p == 0) return 1;
    if(p % 2) return  x * modpow(x, p - 1) % mod;
    else {
        ll res = modpow(x, p / 2);
        return res * res % mod;
    }
}

ll comb(ll n, ll r){
    ll mul = 1;  //n!
    ll div1, div2;
    rep(i, 1, n + 1){
        mul *= i;
        mul %= mod;
        if(i == r) div1 = modpow(mul, mod - 2);  //r!
        if(i == n - r) div2 = modpow(mul, mod - 2); //(n-r)!
    }
    return mul * div1 % mod * div2 % mod;
}


int main() {
    ll n, m;
    cin >> n >> m;
    VE a(n);
    REP(i, n) cin >> a[i];
    VE sum(n + 1, 0);
    rep(i, 1, n + 1) sum[i] = sum[i - 1] + a[i - 1];
    jkl;
    map<ll, ll> mp;
    REP(i, n + 1) mp[sum[i] % m]++;
    ll ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->second < 2)continue;
        ans += comb(itr->second, 2);
    }
    print(ans);
}#include <iostream>
#include "bits/stdc++.h"

using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i, a, b) for(ll i=a;i<b;i++)
#define REP(i, a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i, a) for(ll i=a;i>0;i--)
#define rrep(i, a, b) for(ll i=a-1;i>=b;i--)
#define printall(n, array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
typedef vector<vector<ll>> VVE;
const ll mod = 1e9 + 7; //10^9+7

int main() {
    ll n, m;
    cin >> n >> m;
    VE a(n);
    REP(i, n) cin >> a[i];
    VE sum(n + 1, 0);
    rep(i, 1, n + 1) sum[i] = sum[i - 1] + a[i - 1];
    jkl;
    ll ans = 0;
    rep(i, 0, n + 1)rep(j, i + 1, n + 1){
        if((sum[j] - sum[i]) % m)continue;
        ans++;
    }
    print(ans);
}







