#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
int n, m;
unordered_map<int, long long> mp;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    mp.clear();
    long long ans = 0, sum = 0, a = 0;
    for (int i = 0; i < n; i++) {
      scanf("%lld", &a);
      sum = (sum + a) % m;
      ans += mp[sum]++;
    }
    ans += mp[sum];
    printf("%lld\n", ans);
  }
  return 0;
}
