#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
vector<int> memo;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) A[i] %= M;
  vector<int> sum(N + 1, 0);
  for (int i = 1; i <= N; i++) {
    sum[i] = A[i - 1];
  }
  for (int i = 1; i <= N; i++) {
    sum[i] += sum[i - 1];
  }
  for (int i = 0; i <= N; i++) {
    sum[i] %= M;
  }
  ll ans = 0;
  map<int, int> memo;
  for (int i = 0; i <= N; i++) {
    ans += memo[sum[i]];
    memo[sum[i]]++;
  }
  cout << ans << endl;
  return 0;
}
