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