#include <bits/stdc++.h>
using namespace std;
map<long long, long long> Map;
long long N, M, Sum, Ans;
int main() {
  long long I, J, K;
  scanf("%lld%lld", &N, &M);
  Map[0]++;
  for (I = 1; I <= N; I++) {
    long long Num;
    scanf("%lld", &Num);
    Sum = (Num + Sum) % M;
    Ans += Map[Sum]++;
  }
  printf("%LLd", Ans);
  return 0;
}
