#include <bits/stdc++.h>
using namespace std;
multiset<int> co;
long long sum = 0;
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  co.insert(0);
  for (int i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    sum = (sum + a) % m;
    using iterator = decltype(co)::iterator;
    pair<iterator, iterator> pa = co.equal_range(sum);
    ans += distance(pa.first, pa.second);
    co.insert(sum);
  }
  cout << ans << endl;
  return 0;
}
