Let m and M be the sum of the minima and maxima of all subsets. Since the diameter of a set is the difference between its maximum and its minimum, the desired sum is M−m. We may include unitary subsets, since their minima and maxima coincide.
The number k, 1≤k≤n, is the minimum of all subsets of the form {k}∪A, where A⊂{k+1,k+2,…,n}. So k is the minimum of 2n−k subsets. Hence
m=k=1∑nk⋅2n−k=k=0∑n−1(n−k)⋅2k.
Now we count the number of subsets with diameter k. Let a be the minimum of a subset. The maximum is a+k. Since a+k≤n, one may choose a in n−k ways. Since there are k−1 numbers between a and a+k, there are (n−k)⋅2k−1 subsets with diameters k. Since there are 2n−n−1 non-empty and non-unitary subsets,
k=1∑n−1(n−k)⋅2k−1⟺k=1∑n−1(n−k)⋅2k⟺k=0∑n−1(n−k)⋅2k=2n−n−1=2n+1−2n−2=2n+1−2n−2+n=2n+1−n−2
and m=2n+1−n−2.
In order to compute M, notice that the association A={a1,a2,…,am}→f(A)={n+1−a1,n+1−a2,…,n+1−am} is clearly a bijection that transform minima ℓ in maxima n+1−ℓ. Since there are 2n−1 non-empty subsets, M+m=(n+1)(2n−1)⟺M−m=(n+1)(2n−1)−2(2n+1−n−2)=(n−3)⋅2n+n+3.