#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m, i, j, ans, cur;
  cin >> n >> m;
  vector<long> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  multiset<long> p;
  p.insert(0);
  cur = 0;
  ans = 0;
  for (i = 0; i < n; i++) {
    cur = (cur + a[i]) % m;
    ans += p.count(cur);
    p.insert(cur);
  }
  cout << ans << endl;
  return 0;
}
