#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long INFL = 1000000000000000010;
int INF = 1000000000;
long long MOD = 1000000007;
long long dp1[5010];
long long dp2[30000000];
int main(void) {
  long long N, M;
  cin >> N >> M;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];
  vector<long long> S(N + 1, 0);
  for (long long i = 0; i < N + 1; i++) S[i] = (S[i - 1] + A[i - 1]) % M;
  sort(S.begin(), S.end());
  S.push_back(M);
  int cnt = 1;
  long long ans = 0;
  for (long long i = 0; i < N + 1; i++) {
    if (S[i] == S[i + 1])
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  cout << ans << endl;
}
