#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int acc = 0;
  int ans = 0;
  cin >> n >> m;
  unordered_map<int, int> mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    acc = (acc + a) % m;
    int mod = acc % m;
    if (mod == 0) {
      ans++;
    }
    mp[mod]++;
  }
  for (auto it = mp.begin(); it != mp.end(); ++it) {
    int k = it->second;
    ans += k * (k - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
