#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
    int n,m;cin>>n>>m;
    vi v(100001);
    rep(i,n)cin>>v[i];
    vector<ll> ru;
    map<int,int> mod;
    rep(i,n){
        if(i==0){
            ru.pb(v[0]);
            if(mod.count(ru[i]%m)){
                mod[ru[i]%m]++;
            }else{
                mod.insert(make_pair(ru[i]%m,1));
            }
        }else{
            ru.pb(ru[i-1]+v[i]);
            if(mod.count(ru[i]%m)){
                mod[ru[i]%m]++;
            }else{
                mod.insert(make_pair(ru[i]%m,1));
            }
        }
    }
    ll ans = 0;
    ll key = 0;
    rep(i,m){
        if(mod.count(i)){
            key = mod.at(i);
            if(i==0)ans += key ;
           // cout<<ans<<endl;
            ans += key*(key-1)/2;
        }else{

        }
    }
    cout<<ans<<endl;
    return 0;
}


