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