#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct cell{
  long key;
  int count;
  struct cell *next;
} data;

int insert(long hash,long key);
int search(long hash,long key);

data *h[100005];

int main(void){
  int N,i,j,v;
  long M,a[100005],n[100005],count,m;
  char str[1100000],*p;
  data *t;
  
  for(i=0;i<N;i++){
    h[i]=NULL;
  }
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  N=atoi(p);
  p=strtok(NULL," \n");
  M=atol(p);
  a[0]=0;
  n[0]=0;
  t=malloc(sizeof(data));
  t->key=0;
  t->count=1;
  t->next=h[0];
  h[0]=t;
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a[1]=atol(p);
  n[1]=n[0]+a[1];
  m=n[1]%M;
  insert(m%N,m);
  for(i=2;i<N+1;i++){
    p=strtok(NULL," \n");
    a[i]=atol(p);
    n[i]=n[i-1]+a[i];
    m=n[i]%M;
    insert(m%N,m);
  }
  
  for(i=1,count=0;i<N+1;i++){
    m=n[i]%M;
    v=search(m%N,m);
    count+=v*(v-1)/2;
  }
  
  printf("%ld\n",count);
  
  
  return 0;
}

int insert(long hash,long key){
  data *p;
  if(h[hash]==NULL){
    p=malloc(sizeof(data));
    p->key=key;
    p->count=1;
    p->next=h[hash];
    h[hash]=p;
    return 0;
  }else{
    p=h[hash];
    while(p!=NULL){
      if(p->key==key){
        p->count++;
        return 0;
      }
      p=p->next;
    }
    p=malloc(sizeof(data));
    p->key=key;
    p->count=1;
    p->next=h[hash];
    h[hash]=p;
  }
  
  return 0;
}

int search(long hash,long key){
  data *p,*q;
  int n;
  if(h[hash]==NULL){
    return 0;
  }else{
    p=h[hash];
    if(p->key==key){
      n=p->count;
      h[hash]=p->next;
      free(p);
      return n;
    }
    q=p,p=p->next;
    while(p!=NULL){
      if(p->key==key){
        n=p->count;
        q->next=p->next;
        free(p);
        return n;
      }
      q=p,p=p->next;
    }
  }
  return 0;
}