#include <bits/stdc++.h>
using namespace std;
const int N = 2000100;
const int mod = (int)pow(10, 9) + 7;
const long long INF = 1LL << 60;
string yn(bool b) { return (b ? "Yes" : "No"); }
string YN(bool b) { return (b ? "YES" : "NO"); }
long long n, m, ans;
map<long long, long long> mp;
vector<long long> v;
long long fact[N], inv[N];
long long ppow(long long x, long long n) {
  long long ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) ans = ans * x;
    x = x * x;
    n >>= 1;
    x %= mod;
    ans %= mod;
  }
  return ans;
}
void setinv(long long n) {
  fact[0] = 1;
  inv[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    inv[i] = ppow(fact[i], (long long)mod - 2) % mod;
  }
}
long long conv(long long n, long long r) {
  return fact[n] * inv[r] % mod * inv[n - r] % mod;
}
int main() {
  cin >> n >> m;
  setinv(n);
  long long a, sum = 0;
  for (long long i = (long long)0; i < (long long)n; ++i) {
    cin >> a;
    sum += a;
    if (sum % m == 0) ++ans;
    mp[sum % m]++;
    if (mp[sum % m] == 1) v.push_back(sum % m);
  }
  for (long long i = (long long)0; i < (long long)v.size(); ++i) {
    if (mp[v[i]] > 1) ans += conv(mp[v[i]], 2);
  }
  cout << ans << endl;
  return 0;
}
