#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  long long x;
  cin >> x;
  a[0] = x % m;
  for (long long i = 0; i < n - 1; i++) {
    cin >> x;
    a[i + 1] = (a[i] + x) % m;
  }
  set<long long> s{a.begin(), a.end()};
  long long ans = 0;
  for (auto x : s) {
    ans +=
        count(a.begin(), a.end(), x) * (count(a.begin(), a.end(), x) - 1) / 2;
  }
  ans += count(a.begin(), a.end(), 0);
  cout << ans << endl;
}
