#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (auto& i : A) cin >> i;
  for (auto& i : A) i %= M;
  vector<int> sum(N + 1, 0);
  map<int, int> cnt;
  for (auto i = 0; i < N; ++i) ++cnt[sum[i + 1] = ((sum[i] + A[i]) % M)];
  long long ans = count(begin(A), end(A), 0);
  for (auto i = 1; i <= N; ++i) {
    --cnt[sum[i]];
    ans += cnt[(M - sum[i - 1]) % M];
  }
  cout << ans << endl;
}
