#include <bits/stdc++.h>
using namespace std;
map<int, int> v;
int a[100010] = {0};
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int s = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = (a[i] + a[i - 1]) % m;
    if (a[i] == 0) s++;
    s += v[a[i]];
    v[a[i]]++;
  }
  printf("%d\n", s);
  return 0;
}
