#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"import math\n"
"def f(x):return math.factorial(x)\n"
"def g(x):return f(x)//(f(x-2)*f(2))if x>1else 0\n"
"n,m=map(int,input().split())\n"
"b=0\n"
"c={}\n"
"for a in input().split():\n"
"  b+=int(a)\n"
"  c[b%m]=c.get(b%m,0)+1\n"
"print(sum(map(lambda x:g(x),c.values()))+c.get(0,0))\n"
"\"";
  system(s);
  return 0;
}            