#include <bits/stdc++.h>
using namespace std;
int a[100010];
map<int, int> mp;
int main() {
  int n, m, s = 0;
  long long res = 0;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    s += a[i];
    s %= m;
    mp[s]++;
  }
  for (auto c : mp) {
    res += (c.second * (c.second - 1)) / 2;
  }
  res += mp[0];
  printf("%lld", res);
}
