#include <bits/stdc++.h>
using namespace std;
long long a[100001];
int main() {
  int n, m;
  cin >> n >> m;
  a[0] = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) a[i] = (a[i] + a[i - 1]) % m;
  unordered_map<int, int> hash;
  for (int i = 1; i <= n; i++) {
    hash[a[i]]++;
  }
  long long ans = 0;
  for (auto& it : hash) {
    ans += (it.second) * (it.second - 1) / 2;
  }
  ans += hash[0];
  cout << ans << endl;
  return 0;
}
