#include <bits/stdc++.h>
using namespace std;
int N;
long long M;
vector<long long> A;
map<long long, int> nmod;
vector<long long> sum;
int main() {
  freopen("input", "r", stdin);
  scanf("%d %lld", &N, &M);
  A.assign(N, 0LL);
  sum.assign(N + 1, 0LL);
  for (int i = (0); i < (N); i++) {
    scanf("%lld", &A[i]);
    sum[i + 1] = sum[i] + A[i];
  }
  long long sol = 0LL;
  for (int i = (0); i < (N); i++) {
    long long tmp = sum[i + 1] % M;
    sol += nmod[tmp];
    if (tmp == 0) sol++;
    nmod[tmp]++;
  }
  printf("%lld\n", sol);
}
