#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  for (long long i = (0); i < (n); i++) cin >> a[i];
  vector<long long> b(n + 1);
  b[0] = 0;
  for (long long i = (0); i < (n); i++) {
    b[i + 1] = (b[i] + a[i]) % m;
  }
  unordered_map<long long, long long> c;
  for (long long i = (0); i < (n); i++) c[b[i]]++;
  long long ans = 0;
  for (auto i = c.begin(); i != c.end(); ++i)
    ans += i->second * (i->second - 1) / 2;
  for (long long i = (0); i < (n); i++)
    if (!b[i]) ans++;
  cout << ans << endl;
}
