#include <bits/stdc++.h>
using namespace std;
map<int64_t, int> mp;
int main() {
  int n;
  int64_t m;
  cin >> n >> m;
  int64_t s = 0;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    int64_t a;
    cin >> a;
    s = (s + a) % m;
    mp[s]++;
  }
  int64_t cnt = 0;
  map<int64_t, int>::iterator it = mp.begin();
  for (; it != mp.end(); it++) {
    cnt += ((it->second * (it->second - 1)) / 2);
  }
  cout << cnt;
  return 0;
}
