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