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

namespace BOJENJE
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m;
            string s = Console.ReadLine();
            int p = s.IndexOf(" ");
            n = Convert.ToInt32(s.Substring(0, p));
            m = Convert.ToInt32(s.Substring(p + 1));
            int[,] a = new int[n, m];
            int[] x = new int[n];


            for (int i = 0; i < n; i++)
                x[i] = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < n; i++)
                for (int j = 0; j < x[i]; j++)
                {
                    a[i, j] = 1;
                }


            int sum = 0;
            for (int j = 0; j < m; j++)
            {
                int k = 0;
                for (int i = 0; i < n; i++)
                {
                    k += a[i, j];
                }
                sum += k * (n - k);
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
    }
}