// 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.443050897154096x):
#include <iostream>

#include <algorithm>

#include <utility>

#include <vector>

#include <map>

#include <complex>

#include <iomanip>

#include <cmath>

#include <string>

#include <queue>

#include <stack>

#include <cstring>



#define ll long long

#define ld long double

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

#define INF 0x3f3f3f3f3f3f3f3f

#define point complex <double> 

#define pi acos(-1)

#define mod 1000000007





using namespace std;





int main() {

	HS;

	int n, m;

	cin >> n >> m;

	ll sum = 0,ans=0;

	map< int, int > cnt,zer;

	cnt[0] = 1;

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

	{

		int x;

		cin >> x;

		sum += x;

		ans += cnt[sum % m];

		cnt[sum % m]++;

	}

	cout << ans << endl;

	





	return 0;

}