#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
int main() {
  int N;
  cin >> N;
  int M;
  cin >> M;
  vector<int> A(N);
  vector<ll> sum(N + 1);
  map<int, int> mp;
  for (int i = (int)(0); i < (int)(N); i++) {
    cin >> A[i];
    sum[i + 1] = sum[i] + A[i];
    sum[i + 1] %= M;
    mp[sum[i + 1]]++;
  }
  mp[0]++;
  ll ans = 0;
  for (auto u : mp) {
    ans += u.second * (u.second - 1) / 2;
  }
  cout << ans << endl;
}
