#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long ans = 0, sum = 0;
  map<int, int> s;
  for (int i = 0; i < (n); i++) {
    int a;
    cin >> a;
    sum = (sum + a) % m;
    s[sum]++;
  }
  for (auto i : s) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
