#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N, M;
  cin >> N >> M;
  vi A(N);
  rep(i,N) cin >> A[i];

  vi sum(N);
  sum[0] = A[0] % M;
  rep(i,N-1) sum[i+1] = (sum[i] + A[i+1]) % M;
  map<int, int> G;
  ++G[0];
  rep(i,N) ++G[sum[i]];

  ll ans = 0;
  for (auto p : G) {
    ll &v = p.second;
    ans += v*(v-1)/2;
  }

  cout << ans << endl;
  return 0;
}
