#include <bits/stdc++.h>
using namespace std;
const int N = 100505;
long long a[N], sum[N];
map<long long, long long> mp;
int n, m;
long long ans = 0;
int main() {
  mp.clear();
  scanf("%d%d", &n, &m);
  sum[0] = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    sum[i] = sum[i - 1] + a[i];
  }
  for (int i = 1; i <= n; ++i) sum[i] %= m;
  mp[0] = 1;
  for (int i = 1; i <= n; ++i) {
    ans = ans + mp[sum[i]];
    mp[sum[i]] += 1;
  }
  printf("%I64d\n", ans + mp[0]);
  return 0;
}
