#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> amari(m, 0);
  ll ans = 0;
  ll sum = 0;
  for (ll i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    sum += a;
    if (sum % m == 0) ans++;
    ans += amari[sum % m];
    amari[sum % m]++;
  }
  cout << ans << endl;
}
