// 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.446386002365962x):
    /*

      Creator :  bizarre

    */

    #include <bits/stdc++.h>

    #include <math.h>

    using namespace std;

    #define bizarre  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    #define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

    #define ll long long

    #define ld long double

    #define pi acos(-1)

    #define point complex<double>

    const int N = 1e6 + 9, inf = 2e9, mod = 1e9 + 7;

    vector<int> prime_Numbers;

    bool primes[1000005];

    double dot(point a, point b)

    {

        return (conj(a) * b).real();

    }

    double cross(point a, point b)

    {

        return (conj(a) * b).imag();

    }

    /*

    void prime(int n)

    {

        primes[1]=primes[0]=0;

        for(int i=2; i<=n; i++)

            primes[i]=true;

        for(int i=2; i<=n; i++)

        {

            if(primes[i]==true)

            {

                prime_Numbers.push_back(i);

                for(int j=i+i; j<=n; j+=i)

                    primes[j]=false;

            }

        }

    }

    void move1step(long long& a, long long& b, long long q)

    {

        long long c= a-q*b;

        a=b;

        b=c;

    }

    long long egcd(long long r0,long long r1,long long& x0,long long& y0)

    {

        long long x1=0,y1=1;

        x0=1;

        y0=0;

        while(r1)

        {

            long long q=r0/r1;

            move1step(r0,r1,q);

            move1step(x0,x1,q);

            move1step(y0,y1,q);

        }

        return r0;

    }

    bool  solve (long long a, long long b, long long c,long long&x, long long& y)

    {

        long long g=egcd(a,b,x,y);

        int m=c/g;

        x*=m;

        y*=m;

        return c%g==0;

    }

    int gcd(int a, int b)

    {

        if(b==0)

            return a;

        return gcd(b,a%b);

    }

    void PrimeFactorization(int n)

    {

        for(int i=2; i*i<=n; i++)

        {

            int c=0;

            if(n%i==0)

            {

                while(n%i==0)

                {

                    n/=i;

                }



            }

        }



    }

    long long ncrtane(long long n, long long r)

    {

        long long ans=1,cntr=1;

        for(int i=n; i>n-r; i--)

        {

            ans*=i;

            ans/=cntr;

            cntr++;

        }

        return ans;

    }

    int ncr(long long n, long long r)

    {

        return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;

    }



    int npr(long long n, long long r)

    {

        return (fact[n] * inv[n - r]) % mod;

    }

    long long fact[N], inv[N];

    long long fp(long long base, long long exp)

    {

        if (exp == 0)

            return 1;

        long long ans = fp(base, exp / 2);

        ans = (ans * ans) % mod;

        if (exp % 2 != 0)

            ans = (ans * (base % mod)) % mod;

        return ans;

    }



    void pre(long long n)

    {

        fact[0] = 1;

        inv[0] = 1;

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

        {

            fact[i] = (i * fact[i - 1]) % mod;

            inv[i] = fp(fact[i], mod - 2);

        }

    }

    */

    /*

    ll lfts,lftw;

    ll p,f,cnts,cntw,s,w;

    ll ss(ll cnts, ll cntw, ll mxmp)

    {

         for(int i = 0;i<=cnts;i++)

            {

                ll var = i*s,s = 0,e = cntw,mid,ans;

                if(var>p)break;

                while(s<=e)

                {

                    mid = (s+e)/2;

                    if((mid*w)+var<=p)ans = mid,s = mid+1;

                    else e = mid-1;

                }

                if(mxmp<i+mid)mxmp = i+mid,lfts-=i,lftw-=mid;

            }

            return mxmp;

    }

    ll ww(ll cnts, ll cntw, ll mxmp)

    {

        for(int i = 0;i<=cnts;i++)

            {

                ll var = i*s,s = 0,e = cntw,mid,ans;

                if(var>f)break;

                while(s<=e)

                {

                    mid = (s+e)/2;

                    if((mid*w)+var<=f)ans = mid,s = mid+1;

                    else e = mid-1;

                }

                if(mxmp<i+mid)mxmp = i+mid;

            }

            return mxmp;

    }

    */

    int main()

    {

        bizarre

        ll n,k;

        cin >> n >> k;

        map<int,int>mp;

        mp[0]++;

        ll ans = 0;

        ll sum = 0;

        ll a[n+2];

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

        {

            cin >> a[i];

            sum+=a[i];

            sum%=k;

            ans+=mp[sum];

            mp[sum]++;

        }

        cout << ans;

        return 0;

    }