program Krug2ZadatakD;
 Var
   i,j,N,M : integer;
   B:array[1..100000, 1..10000] of shortint;
   A:array[1..100000] of integer;

   u,s:integer;

begin
  read(N,M);
  for i:=1 to N do
  begin
    read (A[i]);
    if A[i] = M then
       A[i]:=0;

    for j:=1 to A[i] do
        B[i,j]:=1;
    for j:=A[i]+1 to M do
        B[i,j]:=0;
  end;
  u:=0;
  for j:=1 to M do
  begin
    s:=0;

    for i:=1 to N do
        s:=s+B[i,j];

    u:=u+s*(N-s);
  end;
  write(u);

end.