#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 pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  ll n,m;
  cin >> n >> m;
  ll a[n]={};
  rep(i,n)cin >> a[i];
  ll l[n+1]={};
  rep(i,n){
    if(i==0)l[i+1]=a[i]%m;
    else{
      l[i]=l[i-1]+a[i];
      l[i]%=m;
    }
  }
  map<ll,ll> mp;
  rep(i,n+1){
    mp[l[i]]++;
  }
  ll ans=0;
  for(auto i=mp.begin();i!=mp.end();i++){
    ll x=i->second;
   ans+=x*(x-1)/2;
  }
  cout << ans << endl;
return 0;}