*****************************************************************************
*       www.FindStat.org - The Combinatorial Statistic Finder               *
*                                                                           *
*       Copyright (C) 2019 The FindStatCrew <info@findstat.org>             *
*                                                                           *
*    This information is distributed in the hope that it will be useful,    *
*    but WITHOUT ANY WARRANTY; without even the implied warranty of         *
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                   *
*****************************************************************************

-----------------------------------------------------------------------------
Statistic identifier: St000567

-----------------------------------------------------------------------------
Collection: Integer partitions

-----------------------------------------------------------------------------
Description: The sum of the products of all pairs of parts.

This is the evaluation of the second elementary symmetric polynomial which is equal to
$$e_2(\lambda) = \binom{n+1}{2} - \sum_{i=1}^\ell\binom{\lambda_i+1}{2}$$
for a partition $\lambda = (\lambda_1,\dots,\lambda_\ell) \vdash n$, see [1].

This is the maximal number of inversions a permutation with the given shape can have, see [2, cor.2.4].

-----------------------------------------------------------------------------
References: [1]   Kopitzke, G. The Gini Index of an Integer Partition [[arXiv:2005.04284]]
[2]   Hohlweg, C. Minimal and maximal elements in Kazhdan-Lusztig double sided cells of $S_n$ and Robinson-Schensted correspondance [[arXiv:math/0304059]]

-----------------------------------------------------------------------------
Code:
def statistic(L):
    return sum(L[a]*L[b] for a,b in Subsets(range(len(L)), 2))


-----------------------------------------------------------------------------
Statistic values:

[2]                       => 0
[1,1]                     => 1
[3]                       => 0
[2,1]                     => 2
[1,1,1]                   => 3
[4]                       => 0
[3,1]                     => 3
[2,2]                     => 4
[2,1,1]                   => 5
[1,1,1,1]                 => 6
[5]                       => 0
[4,1]                     => 4
[3,2]                     => 6
[3,1,1]                   => 7
[2,2,1]                   => 8
[2,1,1,1]                 => 9
[1,1,1,1,1]               => 10
[6]                       => 0
[5,1]                     => 5
[4,2]                     => 8
[4,1,1]                   => 9
[3,3]                     => 9
[3,2,1]                   => 11
[3,1,1,1]                 => 12
[2,2,2]                   => 12
[2,2,1,1]                 => 13
[2,1,1,1,1]               => 14
[1,1,1,1,1,1]             => 15
[7]                       => 0
[6,1]                     => 6
[5,2]                     => 10
[5,1,1]                   => 11
[4,3]                     => 12
[4,2,1]                   => 14
[4,1,1,1]                 => 15
[3,3,1]                   => 15
[3,2,2]                   => 16
[3,2,1,1]                 => 17
[3,1,1,1,1]               => 18
[2,2,2,1]                 => 18
[2,2,1,1,1]               => 19
[2,1,1,1,1,1]             => 20
[1,1,1,1,1,1,1]           => 21
[8]                       => 0
[7,1]                     => 7
[6,2]                     => 12
[6,1,1]                   => 13
[5,3]                     => 15
[5,2,1]                   => 17
[5,1,1,1]                 => 18
[4,4]                     => 16
[4,3,1]                   => 19
[4,2,2]                   => 20
[4,2,1,1]                 => 21
[4,1,1,1,1]               => 22
[3,3,2]                   => 21
[3,3,1,1]                 => 22
[3,2,2,1]                 => 23
[3,2,1,1,1]               => 24
[3,1,1,1,1,1]             => 25
[2,2,2,2]                 => 24
[2,2,2,1,1]               => 25
[2,2,1,1,1,1]             => 26
[2,1,1,1,1,1,1]           => 27
[1,1,1,1,1,1,1,1]         => 28
[9]                       => 0
[8,1]                     => 8
[7,2]                     => 14
[7,1,1]                   => 15
[6,3]                     => 18
[6,2,1]                   => 20
[6,1,1,1]                 => 21
[5,4]                     => 20
[5,3,1]                   => 23
[5,2,2]                   => 24
[5,2,1,1]                 => 25
[5,1,1,1,1]               => 26
[4,4,1]                   => 24
[4,3,2]                   => 26
[4,3,1,1]                 => 27
[4,2,2,1]                 => 28
[4,2,1,1,1]               => 29
[4,1,1,1,1,1]             => 30
[3,3,3]                   => 27
[3,3,2,1]                 => 29
[3,3,1,1,1]               => 30
[3,2,2,2]                 => 30
[3,2,2,1,1]               => 31
[3,2,1,1,1,1]             => 32
[3,1,1,1,1,1,1]           => 33
[2,2,2,2,1]               => 32
[2,2,2,1,1,1]             => 33
[2,2,1,1,1,1,1]           => 34
[2,1,1,1,1,1,1,1]         => 35
[1,1,1,1,1,1,1,1,1]       => 36
[10]                      => 0
[9,1]                     => 9
[8,2]                     => 16
[8,1,1]                   => 17
[7,3]                     => 21
[7,2,1]                   => 23
[7,1,1,1]                 => 24
[6,4]                     => 24
[6,3,1]                   => 27
[6,2,2]                   => 28
[6,2,1,1]                 => 29
[6,1,1,1,1]               => 30
[5,5]                     => 25
[5,4,1]                   => 29
[5,3,2]                   => 31
[5,3,1,1]                 => 32
[5,2,2,1]                 => 33
[5,2,1,1,1]               => 34
[5,1,1,1,1,1]             => 35
[4,4,2]                   => 32
[4,4,1,1]                 => 33
[4,3,3]                   => 33
[4,3,2,1]                 => 35
[4,3,1,1,1]               => 36
[4,2,2,2]                 => 36
[4,2,2,1,1]               => 37
[4,2,1,1,1,1]             => 38
[4,1,1,1,1,1,1]           => 39
[3,3,3,1]                 => 36
[3,3,2,2]                 => 37
[3,3,2,1,1]               => 38
[3,3,1,1,1,1]             => 39
[3,2,2,2,1]               => 39
[3,2,2,1,1,1]             => 40
[3,2,1,1,1,1,1]           => 41
[3,1,1,1,1,1,1,1]         => 42
[2,2,2,2,2]               => 40
[2,2,2,2,1,1]             => 41
[2,2,2,1,1,1,1]           => 42
[2,2,1,1,1,1,1,1]         => 43
[2,1,1,1,1,1,1,1,1]       => 44
[1,1,1,1,1,1,1,1,1,1]     => 45
[11]                      => 0
[10,1]                    => 10
[9,2]                     => 18
[9,1,1]                   => 19
[8,3]                     => 24
[8,2,1]                   => 26
[8,1,1,1]                 => 27
[7,4]                     => 28
[7,3,1]                   => 31
[7,2,2]                   => 32
[7,2,1,1]                 => 33
[7,1,1,1,1]               => 34
[6,5]                     => 30
[6,4,1]                   => 34
[6,3,2]                   => 36
[6,3,1,1]                 => 37
[6,2,2,1]                 => 38
[6,2,1,1,1]               => 39
[6,1,1,1,1,1]             => 40
[5,5,1]                   => 35
[5,4,2]                   => 38
[5,4,1,1]                 => 39
[5,3,3]                   => 39
[5,3,2,1]                 => 41
[5,3,1,1,1]               => 42
[5,2,2,2]                 => 42
[5,2,2,1,1]               => 43
[5,2,1,1,1,1]             => 44
[5,1,1,1,1,1,1]           => 45
[4,4,3]                   => 40
[4,4,2,1]                 => 42
[4,4,1,1,1]               => 43
[4,3,3,1]                 => 43
[4,3,2,2]                 => 44
[4,3,2,1,1]               => 45
[4,3,1,1,1,1]             => 46
[4,2,2,2,1]               => 46
[4,2,2,1,1,1]             => 47
[4,2,1,1,1,1,1]           => 48
[4,1,1,1,1,1,1,1]         => 49
[3,3,3,2]                 => 45
[3,3,3,1,1]               => 46
[3,3,2,2,1]               => 47
[3,3,2,1,1,1]             => 48
[3,3,1,1,1,1,1]           => 49
[3,2,2,2,2]               => 48
[3,2,2,2,1,1]             => 49
[3,2,2,1,1,1,1]           => 50
[3,2,1,1,1,1,1,1]         => 51
[3,1,1,1,1,1,1,1,1]       => 52
[2,2,2,2,2,1]             => 50
[2,2,2,2,1,1,1]           => 51
[2,2,2,1,1,1,1,1]         => 52
[2,2,1,1,1,1,1,1,1]       => 53
[2,1,1,1,1,1,1,1,1,1]     => 54
[1,1,1,1,1,1,1,1,1,1,1]   => 55
[12]                      => 0
[11,1]                    => 11
[10,2]                    => 20
[10,1,1]                  => 21
[9,3]                     => 27
[9,2,1]                   => 29
[9,1,1,1]                 => 30
[8,4]                     => 32
[8,3,1]                   => 35
[8,2,2]                   => 36
[8,2,1,1]                 => 37
[8,1,1,1,1]               => 38
[7,5]                     => 35
[7,4,1]                   => 39
[7,3,2]                   => 41
[7,3,1,1]                 => 42
[7,2,2,1]                 => 43
[7,2,1,1,1]               => 44
[7,1,1,1,1,1]             => 45
[6,6]                     => 36
[6,5,1]                   => 41
[6,4,2]                   => 44
[6,4,1,1]                 => 45
[6,3,3]                   => 45
[6,3,2,1]                 => 47
[6,3,1,1,1]               => 48
[6,2,2,2]                 => 48
[6,2,2,1,1]               => 49
[6,2,1,1,1,1]             => 50
[6,1,1,1,1,1,1]           => 51
[5,5,2]                   => 45
[5,5,1,1]                 => 46
[5,4,3]                   => 47
[5,4,2,1]                 => 49
[5,4,1,1,1]               => 50
[5,3,3,1]                 => 50
[5,3,2,2]                 => 51
[5,3,2,1,1]               => 52
[5,3,1,1,1,1]             => 53
[5,2,2,2,1]               => 53
[5,2,2,1,1,1]             => 54
[5,2,1,1,1,1,1]           => 55
[5,1,1,1,1,1,1,1]         => 56
[4,4,4]                   => 48
[4,4,3,1]                 => 51
[4,4,2,2]                 => 52
[4,4,2,1,1]               => 53
[4,4,1,1,1,1]             => 54
[4,3,3,2]                 => 53
[4,3,3,1,1]               => 54
[4,3,2,2,1]               => 55
[4,3,2,1,1,1]             => 56
[4,3,1,1,1,1,1]           => 57
[4,2,2,2,2]               => 56
[4,2,2,2,1,1]             => 57
[4,2,2,1,1,1,1]           => 58
[4,2,1,1,1,1,1,1]         => 59
[4,1,1,1,1,1,1,1,1]       => 60
[3,3,3,3]                 => 54
[3,3,3,2,1]               => 56
[3,3,3,1,1,1]             => 57
[3,3,2,2,2]               => 57
[3,3,2,2,1,1]             => 58
[3,3,2,1,1,1,1]           => 59
[3,3,1,1,1,1,1,1]         => 60
[3,2,2,2,2,1]             => 59
[3,2,2,2,1,1,1]           => 60
[3,2,2,1,1,1,1,1]         => 61
[3,2,1,1,1,1,1,1,1]       => 62
[3,1,1,1,1,1,1,1,1,1]     => 63
[2,2,2,2,2,2]             => 60
[2,2,2,2,2,1,1]           => 61
[2,2,2,2,1,1,1,1]         => 62
[2,2,2,1,1,1,1,1,1]       => 63
[2,2,1,1,1,1,1,1,1,1]     => 64
[2,1,1,1,1,1,1,1,1,1,1]   => 65
[1,1,1,1,1,1,1,1,1,1,1,1] => 66

-----------------------------------------------------------------------------
Created: Aug 07, 2016 at 13:18 by Martin Rubey

-----------------------------------------------------------------------------
Last Updated: Nov 09, 2021 at 15:38 by Martin Rubey