#include <bits/stdc++.h>
using namespace std;
int main() {
  using ll = long long;
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n + 1);
  vector<ll> s(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    s[i] = (s[i - 1] + a[i]) % m;
  }
  map<ll, ll> cm;
  for (int i = 1; i <= n; i++) {
    cm[s[i]]++;
  }
  int count = 0;
  for (auto itr = cm.begin(); itr != cm.end(); itr++) {
    ll key = (*itr).first;
    ll val = (*itr).second;
    if (key == 0) count += val;
    if (val > 1) {
      count += val * (val - 1) / 2;
    }
  }
  cout << count << endl;
}
