Artificial intelligent assistant

Minimum sum of set whose average of subsets is positive integer A finite set of positive integers $A$ is called _meanly_ if for each of its nonempty subsets the arithmetic mean of its elements is also a positive integer. In other words, $A$ is meanly if $\frac{1}{k}(a_1 + \dots + a_k)$ is an integer whenever $k \ge 1$ and $a_1, \dots, a_k \in A$ are distinct. Given a positive integer $n$, what is the least possible sum of the elements of a meanly $n$-element set? Source: Middle European Math Competition

For motivation, let's do some small ones by hand. For $n=1$, the set can be $\\{1\\}$ with sum $1$. For $n=2$, we can put $1$ in, but then we can't have $2$, which would give mean $\frac 32$ for the whole set. But $\\{1,3\\}$ with sum $4$ works. It should be clear that if $n \ge 2$ all the numbers have to have the same parity. For $n=3$, then, we can't use $4$, but $\\{1,3,5\\}$ with sum $9$ works. But if $n\ge 4$, we can't have all of $1,3,5$, as whatever the fourth element $k$ is, either $\\{1,3,k\\}$ or $\\{1,5,k\\}$ will not have an integral mean. The best we can do is $\\{1,7,13,19\\}$ with sum $40$

This indicates that all the numbers in the set must be equivalent $\pmod {\operatorname{lcm}(1,2,3,\dots n-1)}$ Let $p=\operatorname{lcm}(1,2,3,\dots n-1)$, then our set is $\\{1,1+p,1+2p,\dots 1+(n-1)p\\}$ with sum $\frac 12np(n-1)+n$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 2b5b7e3d736822b3b653f94732812f61