#include <bits/stdc++.h>
using namespace std;
map<int, int> counter;
void push(int num) {
  if (counter.find(num) == counter.end())
    counter[num] = 1;
  else
    counter[num]++;
}
int query(int num) {
  if (counter.find(num) == counter.end()) return 0;
  return counter[num];
}
int main() {
  int n, m;
  int sum = 0, ans = 0;
  push(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    sum = (sum + a % m) % m;
    ans += query(sum);
    push(sum);
  }
  cout << ans << endl;
  return 0;
}
