#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int i, k, now = 0, ans = 0;
  unordered_map<int, int> mp;
  mp[0] = 1;
  for (i = 0; i < n; i++) {
    scanf("%d", &k);
    now += k;
    now %= m;
    ans += mp[now];
    mp[now]++;
  }
  printf("%d", ans);
}
