#include <bits/stdc++.h>
using namespace std;
int n, m;
int sum, ans;
map<int, int> L;
int main() {
  register int i;
  int x;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    sum = (sum + x) % m;
    ans += L[sum];
    L[sum]++;
  }
  printf("%d", ans + L[0]);
  return 0;
}
