#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
long long a[N];
map<int, int> cnt;
int main() {
  long long n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i];
  long long ans = 0, pre = 0;
  cnt[0] = 1;
  for (int i = 1; i <= n; i++) {
    pre += a[i];
    pre %= k;
    ans += cnt[pre];
    cnt[pre]++;
  }
  cout << ans << endl;
}
