#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const long long llINF = 10000000000000000;
const int MOD = 1000000007;
int main() {
  int* sousuu;
  int N, M;
  int A[100100];
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sousuu = (int*)malloc(M * sizeof(int));
  for (int i = 0; i < M; i++) {
    sousuu[i] = 0;
  }
  int wa = 0;
  sousuu[0] = 1;
  for (int i = 0; i < N; i++) {
    wa = (wa + A[i]) % M;
    sousuu[wa]++;
  }
  long long joukenmitasu = 0;
  for (int i = 0; i < M; i++) {
    joukenmitasu += (sousuu[i] * (sousuu[i] - 1)) / 2;
  }
  printf("%lld\n", joukenmitasu);
  free(sousuu);
}
