using System;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int n = int.Parse(array[0]);
        int m = int.Parse(array[1]);
        array = Console.ReadLine().Split(' ');
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = int.Parse(array[i]);

        int[] sum = new int[n + 1];
        sum[0] = 0;
        for (int i = 0; i < n; i++)
            sum[i + 1] = (a[i] + sum[i]) % m;

        long ans = 0;
        for (int i = 0; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                if (sum[i] == sum[j]) ans++;
            }
        }

        Console.WriteLine(ans);
    }
}