#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> s(N + 1);
  s[0] = 0;
  ll a = 0;
  for (ll i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    s[i + 1] = a = (a + tmp) % M;
  }
  sort(s.begin(), s.end());
  ll sum = 0;
  ll streak = 0;
  ll current = -1;
  for (ll si : s) {
    if (si == current) {
      streak++;
    } else {
      streak = 0;
      current = si;
    }
    sum += streak;
  }
  cout << sum << endl;
  return 0;
}
