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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N+1);
  rep(i, 0, N) cin >> A[i];
  rep(i, 0, N) B[i+1] = (B[i] + A[i]) % M;
  long long ans = 0;
  map<int, int> mp;
  rep(i, 0, N + 1) {
    mp[B[i]]++;
    ans += mp[B[i]] - 1;
  }
  cout << ans << endl;
  return 0;
}