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

int main(){
  unsigned long int n, m;
  unsigned long int *a = NULL;
  int i;
  unsigned long int comb_num = 0;
  scanf( "%lu", &n );
  scanf( "%lu", &m );
  a = ( unsigned long int* )malloc( sizeof( unsigned long int ) * n );
  for ( i = 0; i < n; i++ ){
    scanf( "%lu", &a[ i ] );
    if ( a[ i ] % m == 0 ){
      comb_num++;
    }
    //printf( "%d ", a[i] );
  }
  int l = 0, r = 0;

  // for ( l = 0; l < n; l++ ){
  //   for ( r = l; r < n; r++ ){
  //     int j;
  //     unsigned long int sum = 0;
  //     for ( j = l; j <= r; j++ ){
  //       sum += a[ j ];
  //     }
  //     if ( sum % m == 0 ){
  //       comb_num++;
  //     }
  //   }
  // }
  // unsigned long int sum = 0;
  // for ( l = 0; l < n; l++ ){
  // sum = 0;
  //   for ( r = l; r < n; r++ ){
  //     sum += a[ r ];
  //     //printf("%lu\n", sum);
  //     if ( sum % m == 0 ){
  //       comb_num++;
  //     }
  //   }
  // }
  unsigned long int sum[ n ][ n ];
  sum[ 0 ][ 0 ] = a[ 0 ];
  if ( sum[ 0 ][ 0 ] )
  for ( r = 1; r < n; r++ ){
    sum[ 0 ][ r ] = a[ r ] + sum[ 0 ][ r - 1 ];
    if ( sum[ 0 ][ r ] % m == 0 )
      comb_num++;
  }
  for ( l = 1; l < n; l++ ){
    for ( r = l + 1; r < n; r++ ){
      sum[ l ][ r ] = sum[ l - 1 ][ r ] - a[ l - 1 ];
      if ( sum[ l ][ r ] % m == 0 )
         comb_num++;
  }

  printf( "%lu\n", comb_num );
  
  return 0;
}