#include <bits/stdc++.h>
using namespace std;
long long a[110000];
long long sum[110000];
map<long long, long long> cnt;
int main() {
  long long n, m;
  sum[0] = 0;
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    sum[i] = (sum[i - 1] + a[i]) % m;
  }
  sort(sum, sum + n + 1);
  long long s = 1;
  long long ans = 0;
  for (long long i = 1; i <= n; i++) {
    if (sum[i] == sum[i - 1])
      s++;
    else {
      ans += s * (s - 1) / 2;
      s = 1;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
