#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long fact_mod(long long n, long long mod) {
  long long f = 1;
  for (int i = 2; i <= n; i++) f = f * (i % MOD) % MOD;
  return f;
}
long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}
long long combination_mod(long long n, long long r, long long mod) {
  if (r > n - r) r = n - r;
  if (r == 0) return 1;
  long long a = 1;
  for (int i = 0; i < r; i++) a = a * ((n - i) % mod) % mod;
  long long b = mod_pow(fact_mod(r, mod), mod - 2, mod);
  return (a % mod) * (b % mod) % mod;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> acc(n + 1);
  acc[0] = 0LL;
  map<long long, long long> M;
  M[0]++;
  for (int i = 1; i <= n; i++) {
    cin >> acc[i];
    acc[i] += acc[i - 1];
    acc[i] %= m;
    M[acc[i]]++;
  }
  long long ans = 0LL;
  for (auto itr : M) {
    if (itr.second >= 2) {
      ans += combination_mod(itr.second, 2, MOD);
    }
  }
  cout << ans << endl;
  return 0;
}
