#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, i, a;
  unsigned long long B;
  map<int, int> _map;
  unsigned long long n = 0;
  unsigned long long sum = 0;
  cin >> N >> M;
  B = 0;
  _map.insert(make_pair(0, 1));
  for (i = 1; i <= N; i++) {
    cin >> a;
    B += a;
    _map[B % M]++;
  }
  for (auto j = _map.begin(); j != _map.end(); j++) {
    a = j->second;
    n += a * (a - 1) / 2;
  }
  cout << n << endl;
  return 0;
}
