#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, int b) {
  return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<long long> acc(n + 1);
  acc.emplace_back(0);
  for (int i = 0; i < (n); ++i) {
    cin >> acc[i + 1];
    acc[i + 1] = (acc[i + 1] + acc[i]) % m;
  }
  map<long long, int> mp;
  for (int i = 0; i < (n + 1); ++i) mp[acc[i]]++;
  long long ans = 0;
  for (auto e : mp) ans += e.second * (e.second - 1) / 2;
  cout << ans << endl;
}
