#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1 << 30;
constexpr int mo = 1e9 + 7;
constexpr ll infl = 1ll << 60;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<ll> s(n);
  map<int, int> mc;
  for (auto& a : s) cin >> a, a %= m;
  for (int i = 1; i < n; ++i) {
    s[i] += s[i - 1];
    s[i] %= m;
  }
  int count = 0;
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 0) {
      ret += count++;
      ret++;
    } else {
      if (mc.count(s[i])) {
        ret += mc[s[i]];
      }
    }
    mc[s[i]]++;
  }
  cout << ret << endl;
  return 0;
}
