// 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.4689314698749434x):
#include<bits/stdc++.h>

using namespace std;

#define ll long long

#define pi 2*acos(0.0)

#define f first

#define s second

#define pb push_back

#define gap ' '

#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

#define mod 1000000007

#define N 100005

ll n,m;

ll ara[N],sum[N];

map<ll,ll> mp;



int main(){

    fastio;

    cin>>n>>m;

    for(int i=1;i<=n;i++){

        cin>>ara[i];

        sum[i]=ara[i]+sum[i-1];

    }

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

        sum[i]%=m;

        mp[sum[i]]++;

    }

    ll ans=0;

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

        mp[sum[i]]--;

        ans+=mp[sum[i]];

    }

    cout<<ans<<endl;

}