Problem

Source: Mexico National Olympiad 2017, Problem 2

Tags: number theory, Average



A set of $n$ positive integers is said to be balanced if for each integer $k$ with $1 \leq k \leq n$, the average of any $k$ numbers in the set is an integer. Find the maximum possible sum of the elements of a balanced set, all of whose elements are less than or equal to $2017$.