#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, pas, jm;
map<long long, long long> m;
int main() {
  cin >> a >> d;
  for (b = 1; b <= a; b++) {
    cin >> c;
    jm += c;
    pas += m[jm % d];
    m[jm % d]++;
  }
  cout << pas;
  return 0;
}
