#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long MOD_9 = 998244353;
int main() {
  long long N, M;
  cin >> N >> M;
  long long A[N];
  vector<long long> Sum(N);
  for (int((i)) = (0); ((i)) < ((N)); (i) += 1) {
    cin >> A[i];
    if (i != 0)
      Sum[i] = Sum[i - 1] + A[i];
    else
      Sum[i] = A[i];
    Sum[i] %= M;
  }
  sort((Sum).begin(), (Sum).end());
  long long cnt = 1;
  long long ans = 0;
  for (int((i)) = (0); ((i)) < ((N)); (i) += 1) {
    if (Sum[i] == 0) ans++;
    if (Sum[i] == Sum[i + 1]) {
      cnt++;
    } else {
      ans += (cnt * (cnt - 1)) / 2;
      cnt = 1;
    }
  }
  ans += (cnt * (cnt - 1)) / 2;
  cout << ans << endl;
}
