#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long box, child;
  cin >> box >> child;
  vector<long long> candy(box);
  long long sum = 0;
  long long A;
  for (long long i = 0; i < box; i++) {
    cin >> A;
    sum += A;
    sum %= child;
    candy[i] = sum;
  }
  map<long long, long long> m;
  m[0]++;
  for (long long i = 0; i < box; i++) {
    m[candy[i]]++;
  }
  int sub = 0;
  for (auto& a : m) {
    if (a.second > 1) {
      sub += a.second * (a.second - 1) / 2;
    }
  }
  cout << sub << endl;
}
