#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
int main(int argc, char const* argv[]) {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n);
  vector<int> s(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  s[0] = a[0] % m;
  for (int i = 1; i < n; ++i) s[i] += ((s[i - 1] + a[i]) % m);
  sort(s.begin(), s.end());
  map<long long, long long> mp;
  long long ans = 0;
  for (int i = 0; i < (n); ++i) {
    if (s[i] == 0) ans++;
    mp[s[i]]++;
  }
  for (auto x : mp) ans += (x.second * (x.second - 1)) / 2;
  cout << ans << endl;
  return 0;
}
