#include <bits/stdc++.h>
using namespace std;
long long z, d, ans, sum;
map<long long, long long> mp;
signed main() {
  cin >> z >> d;
  mp[0]++;
  while (z--) {
    long long x;
    cin >> x;
    sum += x;
    sum %= d;
    ans += mp[(d - sum) % d] + (sum == 0);
    mp[sum]++;
  }
  cout << ans << '\n';
}
