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