#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int A[N];
  int i, j;
  for (i = 0; i < N; i++) cin >> A[i];
  long long sum[N];
  sum[0] = A[0];
  int ans = 0;
  if (sum[0] % M == 0) ans++;
  map<int, int> cnt;
  cnt[sum[0] % M]++;
  for (i = 1; i < N; i++) {
    sum[i] = sum[i - 1] + A[i];
    ans = ans + cnt[sum[i] % M];
    cnt[sum[i] % M]++;
    if (sum[i] % M == 0) ans++;
  }
  cout << ans << "\n";
  return 0;
}
