#include <bits/stdc++.h>
using namespace std;
long long N, M;
const long long MAX_N = 1.0e5 + 100;
long long A[MAX_N];
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> A[i];
  map<long long, long long> cnt;
  cnt[0] = 1;
  long long sum_A[N + 1];
  sum_A[0] = 0;
  for (int i = 1; i <= N; i++) {
    sum_A[i] = sum_A[i - 1] + A[i - 1];
    cnt[sum_A[i] % M]++;
  }
  long long ans = 0;
  for (int i = 0; i < cnt.size(); i++) {
    ans += cnt[i] * (cnt[i] - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
