#include <bits/stdc++.h>
using namespace std;
vector<long long> re;
signed main() {
  long long n, m;
  cin >> n >> m;
  re.resize(m, 0);
  long long a = 0ll, b = 0ll;
  re[0] = 1ll;
  for (long long i = 0; i < n; i++) {
    cin >> a;
    b += a;
    b = (b % m);
    re[b]++;
  }
  long long ans = 0ll;
  for (auto&& w : re) ans += w * (w - 1) / 2;
  cout << ans << endl;
}
