#include <bits/stdc++.h>
using namespace std;
using ll = long long;
set<string> c;
const ll inf = (1e18);
const ll mod = 1000000007;
const ll mod2 = 998244353;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n), sum(n + 1, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
  multiset<ll> s;
  for (int i = 0; i <= n; i++) {
    sum[i] %= m;
    s.insert(sum[i]);
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll comb = s.count(sum[i]);
    if (comb > 0) ans += comb - 1;
    s.erase(s.find(sum[i]));
  }
  cout << ans << endl;
}
