#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  int n;
  long long m;
  cin >> n >> m;
  vector<long long> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  vector<long long> sum(n + 1);
  sum[0] = 0;
  map<long long, int> mp;
  mp[0] = 1;
  for (int i = 0; i < (n); ++i) {
    sum[i + 1] = (sum[i] + a[i]) % m;
    ++mp[sum[i + 1]];
  }
  long long ans = 0;
  for (auto p : mp) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
