#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000;
long long N, M, A[MAX_N];
void solve() {
  unordered_map<long long, long long> mp;
  long long ans = 0;
  long long dp[N + 1];
  for (int i = 0; i < N; ++i) {
    dp[i + 1] = (dp[i] + A[i]) % M;
    mp[dp[i + 1]]++;
  }
  for (auto const &mod : mp) {
    ans += mod.second * (mod.second - 1) / 2;
    if (mod.first == 0) ans += mod.second;
  }
  cout << ans << endl;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; ++i) cin >> A[i];
  solve();
  return 0;
}
