// Slower C++ solution:
/*

    Author: Alam Khan

    AUST CSE 40th Batch



*/



#include<bits/stdc++.h>

using namespace std;



typedef long long ll;

typedef pair<ll,ll> pll;

typedef vector<ll> vl;

typedef deque<ll> dl;

typedef stack<ll> stl;

typedef set<ll> sl;

typedef map<string, ll> msl;

typedef map<ll,ll> mll;

#define sf(n)     scanf("%lld",&n)

#define sff(n,m)     scanf("%lld %lld",&n,&m)

#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)

#define sfs(n)     scanf("%s",n)

#define pf(n)     printf("%lld\n",n)

#define pff(n,m)     printf("%lld %lld\n",n,m)

#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)

#define pfs(n)     printf("%s\n",n)

#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)

#define pb     push_back

#define prf     printf

#define inf     2e18

#define low     -1000000000000

#define PI        acos(-1.0)

#define rep1(i,n) for(i=1;i<n;i++)

#define rep0(i,n) for(i=0;i<n;i++)

#define rep(i,a,n) for(i=a;i<n;i++)

#define repe1(i,n) for(i=1;i<=n;i++)

#define repe0(i,n) for(i=0;i<=n;i++)

#define repe(i,a,n) for(i=a;i<=n;i++)

ll a[100009],arr[100009];

map<ll,ll> ma;

vector<ll> v[100009];

ll sol(ll n)

{

    return (n*(n+1))/2;

}

int main()

{

    ll i,n,t,k,j,x=0,y=0,m;

    sff(n,m);

    rep0(i,n)

    {

        sf(x);

        arr[i] = x;

        if(i==0)

            a[i] = x;

        else a[i] = a[i-1]+x;

        a[i] = a[i]%m;

    }

    ll ind = 0;

    for(i=0;i<n;i++)

    {

        if(ma.find(a[i])==ma.end())

        {

            ma[a[i]] = ind++;

        }

        v[ma[a[i]]].push_back(i);

    }

    /*map<ll,ll> :: iterator it;

    for(it=ma.begin();it!=ma.end();it++)

    {

        cout<<it->first<<endl;

        for(i=0;i<v[it->second].size();i++)

        {

            cout<<v[it->second][i]<<" ";

        }

        cout<<endl;

    }*/

    ll ans =0;

    if(ma.find(0)!=ma.end())

    {

        ans+= v[ma[0]].size();

    }

    x = 0;

    ll hi,lo,mid,temp;

    //cout<<"ans = "<<ans<<endl;

    for(i=0;i<n;i++)

    {

        x+= arr[i];

        x = x%m;

        lo = 0;

        hi = v[ma[x]].size()-1;

        temp  = -1;

        while(lo<=hi)

        {

            mid = (lo+hi)/2;

            if(v[ma[x]][mid]>i)

            {

                temp = mid;

                hi = mid-1;

            }

            else lo = mid+1;

        }

        //pff(x,temp);

        //cout<<v[ma[x]].size()<<endl;

        if(temp!=-1)

        {

            ans+= v[ma[x]].size()-temp;

        }

    }

    pf(ans);





    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.442027931941216x):
#include <bits/stdc++.h>

//#include <ext/pb_ds/assoc_container.hpp>

//using namespace __gnu_pbds;

using namespace std;

typedef long long ll;

typedef long double ld;

//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;

template<class T1, class T2>

ostream &operator <<(ostream &os, pair<T1,T2>&p);

template <class T>

ostream &operator <<(ostream &os, vector<T>&v);

template <class T>

ostream &operator <<(ostream &os, set<T>&v);

template <class T1, class T2>

ostream &operator <<(ostream &os, map<T1,T2>&v);

#ifdef APURBA

#define HERE cout<<"here - "<<__LINE__<<"\n";

#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it)

{

    cout<<endl;

}

template<typename T, typename... Args>

void err(istream_iterator<string> it, T a, Args... args)

{

    cout << *it << " = " << a << " ";

    err(++it, args...);

}

#else

#define HERE

#define debug(args...)

#endif

const int N = 2e5+5;

const ll mod = 998244353 ;

typedef pair<int,int> pii;





void TEST_CASES(int cas)

{

    ll n,m;

    cin>>n>>m;

    vector<ll>a(n);

    vector<ll>p(n+1);

    for(ll i=0;i<n;i++)

    {

        cin>>a[i];

        a[i]%=m;

    }

    for(ll i=1;i<=n;i++)

    {

        p[i] = p[i-1] + a[i-1];

        p[i]%=m;

    }

    map<ll,ll>cnt;

    ll ans = 0;

    for(ll i=0;i<=n;i++)

    {

        ans+= cnt[p[i]];

        cnt[p[i]]++;

    }

    cout<<ans<<"\n";



}







/*



*/



int main()

{

#ifndef APURBA

    ios_base::sync_with_stdio(false);

    cin.tie(nullptr);

#endif

    //freopen("input.txt","r",stdin);

    //freopen("out1.txt","w",stdout);



    int t=1,cas=0;

    //cin>>t;

    while(t--)

    {

        TEST_CASES(++cas);

    }

    return 0;

}







template<class T1, class T2>

ostream &operator <<(ostream &os, pair<T1,T2>&p)

{

    os<<"{"<<p.first<<", "<<p.second<<"} ";

    return os;

}

template <class T>

ostream &operator <<(ostream &os, vector<T>&v)

{

    os<<"[ ";

    for(int i=0; i<v.size(); i++)

    {

        os<<v[i]<<" " ;

    }

    os<<" ]";

    return os;

}



template <class T>

ostream &operator <<(ostream &os, set<T>&v)

{

    os<<"[ ";

    for(T i:v)

    {

        os<<i<<" ";

    }

    os<<" ]";

    return os;

}

template <class T1, class T2>

ostream &operator <<(ostream &os, map<T1,T2>&v)

{

    for(auto i:v)

    {

        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;

    }

    return os;

}