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