#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, m;
int a[maxn], sum[maxn] = {0};
map<int, int> mp;
int 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];
    sum[i] %= m;
    mp[sum[i]]++;
  }
  map<int, int>::iterator iter;
  for (iter = mp.begin(); iter != mp.end(); iter++) {
    int cnt = (iter->second);
    if ((iter->first) == 0)
      ans += cnt + cnt * (cnt - 1) / 2;
    else
      ans += cnt * (cnt - 1) / 2;
  }
  printf("%d", ans);
  return 0;
}
