#include <bits/stdc++.h>
using namespace std;
map<int, int> mm;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int t;
  int sum = 0;
  int ans = 0;
  mm[0]++;
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &t);
    sum = (sum + t) % m;
    ans += mm[sum]++;
  }
  cout << ans << endl;
  return 0;
}
