#include <bits/stdc++.h>
using namespace std;
inline void print() { cout << '\n'; }
template <typename First, typename... Rest>
void print(const First &first, const Rest &...rest) {
  cout << first << ' ';
  print(rest...);
}
const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
void solve() {
  int N, M;
  cin >> N >> M;
  vector<long long> A(N + 1);
  map<int, int> mp;
  set<int> s;
  mp[0]++;
  s.insert(0);
  for (int i = 1; i < N + 1; i++) {
    cin >> A[i];
    A[i] += A[i - 1];
    mp[A[i] % M]++;
    s.insert(A[i] % M);
  }
  COMinit();
  long long ans = 0;
  for (auto e : s) {
    ans += COM(mp[e], 2);
  }
  cout << ans << '\n';
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
