#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool exist[1000000000] = {};
int main(int argc, char const* argv[]) {
  unordered_map<int, int> count;
  int n, m, a, acc = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    acc = (acc + a) % m;
    if (exist[acc])
      count[acc]++;
    else {
      count[acc] = 1;
      exist[acc] = true;
    }
  }
  ll sum = 0;
  for (auto a : count) {
    if (a.first == 0)
      sum += a.second * (a.second + 1) / 2;
    else
      sum += a.second * (a.second - 1) / 2;
  }
  cout << sum << endl;
  return 0;
}
