#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ll long long
using namespace std;
int main(){
  ll n, m;
  cin >> n >> m;
  ll b[m] = {};
  ll c = 0;
  b[0]++;
  REP(i, n){
    ll a;
    cin >> a;
    c += a;
    c %= m;
    b[c]++;
  }
  ll ans = 0;
  REP(i, m){
    if(b[i] > 1)ans += b[i] * (b[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}