#include <bits/stdc++.h>
using namespace std;
int main() {
  uint64_t n, m;
  cin >> n >> m;
  uint64_t a[n];
  for (auto i = 0; i < n; i++) {
    uint64_t v;
    cin >> v;
    a[i] = v;
  }
  uint64_t b[n + 1];
  b[0] = 0;
  uint64_t sum = 0;
  for (auto i = 0; i < n; i++) {
    sum += a[i];
    b[i + 1] = sum;
  }
  unordered_map<uint64_t, uint64_t> um;
  for (auto i = 0; i < n + 1; i++) {
    auto it = um.find(b[i] % m);
    if (it == end(um)) {
      um.insert(make_pair<uint64_t, uint64_t>(b[i] % m, 1));
    } else {
      uint64_t v = it->second;
      um.erase(it);
      um.insert(make_pair<uint64_t, uint64_t>(b[i] % m, v + 1));
    }
  }
  uint64_t ans = 0;
  for (auto&& e : um) {
    int v = e.second;
    ans += (v * v - v) / 2;
  }
  cout << ans << endl;
}
