You are given a sequence of integers a1,a2,…,aN. For a positive integer K, choose real numbers b1,b2,…,bK, which do not have to be integers, so that the value of S is as small as possible.
S=∑i=1Nmin1≤j≤K∣ai−bj∣
For every K from 1 to N, find the smallest possible value of S.