using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			int n = (int)nm[0];
			long m = nm[1];
			long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			long[] sums = new long[n + 1];
			for (int i = 0; i < n; i++) {
				sums[i + 1] = (sums[i] + a[i]) % m;
			}

			var counts = sums.GroupBy(
				x => x,
				(key, e) => new { Value = key, Count = e.Count() })
				.Where(x => x.Count > 1)
				.ToArray();

			ModCounting.InitializeFactorial(n, MOD);

			long ans = 0;
			foreach (var count in counts) {
				long c = ModCounting.Combination(count.Count, 2);
				ans = (ans + c) % MOD;
			}

			Console.WriteLine(ans);
		}
	}

	public static class ModCounting
	{
		private static long p_;

		private static long[] factorial_;
		private static long[] inverseFactorial_;
		private static long[] inverse_;

		public static void InitializeFactorial(long max, long p = 1000000007)
		{
			p_ = p;

			factorial_ = new long[max + 1];
			inverseFactorial_ = new long[max + 1];
			inverse_ = new long[max + 1];

			factorial_[0] = factorial_[1] = 1;
			inverseFactorial_[0] = inverseFactorial_[1] = 1;
			inverse_[1] = 1;
			for (int i = 2; i <= max; i++) {
				factorial_[i] = factorial_[i - 1] * i % p;
				inverse_[i] = p - inverse_[p % i] * (p / i) % p;
				inverseFactorial_[i] = inverseFactorial_[i - 1] * inverse_[i] % p;
			}
		}

		public static long Factorial(long n)
		{
			if (n < 0) {
				return 0;
			}

			return factorial_[n];
		}

		public static long InverseFactorial(long n)
		{
			if (n < 0) {
				return 0;
			}

			return inverseFactorial_[n];
		}

		public static long Inverse(long n)
		{
			if (n < 0) {
				return 0;
			}

			return inverse_[n];
		}

		public static long Permutation(long n, long k)
		{
			if (n < k || (n < 0 || k < 0)) {
				return 0;
			}

			return factorial_[n] * inverseFactorial_[n - k] % p_;
		}

		public static long Combination(long n, long k)
		{
			if (n < k || (n < 0 || k < 0)) {
				return 0;
			}

			return factorial_[n] * (inverseFactorial_[k] * inverseFactorial_[n - k] % p_) % p_;
		}
	}
}
