#include <bits/stdc++.h>
constexpr long long int INF = std::numeric_limits<long long int>::max();
constexpr long long int NINF = std::numeric_limits<long long int>::min();
using namespace std;
map<long long int, long long int> memo;
const long long int MAX = 3 * 100000;
const long long int MOD = 1000000007;
long long int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (long long 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 int COM(long long int n, long long 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() {
  COMinit();
  long long int N, M;
  cin >> N >> M;
  long long int sum = 0;
  memo[0]++;
  while (N--) {
    long long int a;
    cin >> a;
    sum += a;
    memo[sum % M]++;
  }
  long long int ans = 0;
  for (auto pair : memo) {
    long long int cnt = pair.second;
    ans += COM(cnt, 2);
  }
  cout << ans << endl;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
