#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int now = 0;
  map<int, int> mp;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    now = (now + a) % m;
    mp[now]++;
  }
  long long ans = 0;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int sec = itr->second;
    if (sec >= 2) {
      ans += sec * (sec - 1) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
