#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
using namespace std;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

template<typename ...Ts>
void show(Ts... ts){
  cout<<"#:";
  auto print=[](auto v){cout<<v<<" ";};
  initializer_list<int>{(void(print(ts)),0)...};
  cout<<endl;
}

int f[101000];

int fact(int n){
    if (n==0){f[n]=1;return f[n];}
    if (f[n]>0)return f[n];
    f[n]=fact(n-1)*n;
    return f[n];
}


int main(void){
    ll n,m;
    ll ans=0;
    string s;
    cin>>n>>m;
    vi a(n,0);
    vi ac(n+1,0);
    map<ll,ll> mp;mp[0]=1;
    
    rep(i,n)cin>>a[i];
    rep(i,n)ac[i+1]=a[i]+ac[i];
    
    rep(i,n+1){
        ll rm=ac[i]%m;
        mp[rm]+=1;
    }
    for(auto i:mp){
        //cout<<i.first<<' '<<i.second<<endl;
        ll x=i.second;
        ans+=x*(x-1)/2;
    }
    cout<<ans<<endl;
    //solve(t);
}
