#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define vl vector<ll>

int main(){
  int n,m; cin >> n >> m;
  vl a(n); rep(i,n) cin >> a[i];
  vl s(n+1); rep(i,n) s[i+1] = (s[i] + a[i])%m;

  // mapを使って累積和の剰余類ごとの個数を管理
  map<ll,ll> C;
  ll ans = 0LL;
  rep(i,n+1) {
    ans += C[s[i]];
    C[s[i]]++;
  }

  cout << ans << endl;
}
