#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, current, sum, f, s = 0;
  map<int, int> memo;
  long long ans = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &current);
    sum = (sum + current) % m;
    if (memo.find(sum) == memo.end()) {
      memo[sum] = 0;
    }
    memo[sum]++;
  }
  for (map<int, int>::iterator it = memo.begin(); it != memo.end(); ++it) {
    f = it->first;
    s = it->second;
    if (s > 1) ans += (s * (s - 1) / 2);
    if (f == 0) ans += s;
  }
  cout << ans << endl;
  return 0;
}
