#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;
int main() {
  int n, m, c = 0, x;
  map<int, int> mp;
  mp[0]++;
  cin >> n >> m;
  while (n--) cin >> x, c += x, c %= m, mp[c]++;
  long long ans = 0;
  for (auto it : mp) ans += it.second * (it.second - 1) / 2;
  cout << ans;
  return 0;
}
