Let ak=(2k−1)/(2n), k=1,…,n. The required maximum is ∑k=1nf(ak) and is achieved, for instance, at x1=⋯=xn=0 or at x1=⋯=xn=1.
To show that ∑k=1nf(ak) is an upper bound for the sum under consideration subject to the given constraint, fix an n-tuple (x1,…,xn) such that 0≤x1≤⋯≤xn≤1, write [n]={1,…,n}, define an increasing function φ:[n]→[n] by φ(k)=max{j:aj−1/(2n)≤xk}, and notice that
∣xk−ak∣≤∣xk−aφ(k)∣+∣aφ(k)−ak∣≤1/(2n)+∣φ(k)−k∣/n=a∣φ(k)−k∣+1,
for k=1,…,n.
We shall prove that there exists a permutation σ of [n] such that ∣φ(k)−k∣+1≤σ(k) for all k, so a∣φ(k)−k∣+1≤aσ(k) and the conclusion follows:
k=1∑nf(∣xk−ak∣)≤k=1∑nf(a∣φ(k)−k∣+1)≤k=1∑nf(aσ(k))=k=1∑nf(ak).
We now show by induction on n that, for any increasing function ψ:[n]→[n], there exists a permutation σ of [n] such that ∣ψ(k)−k∣+1≤σ(k) for all k.
The base case, n=1, is clear. For the induction step, let n>1 and distinguish two cases.
If ψ(n)<n, then the restriction of ψ to [n−1] is an increasing function of [n−1] into itself, so ∣ψ(k)−k∣+1≤σ(k), k=1,…,n−1, for some permutation σ of [n−1]. Since ∣ψ(n)−n∣+1=n−ψ(n)+1≤n, the permutation σ extends to a permutation of [n] satisfying the required condition by letting σ(n)=n.
If ψ(n)=n, consider the increasing function ψ′:[n−1]→[n−1] defined by ψ′(k)=ψ(k) if ψ(k)<n and ψ′(k)=n−1 if ψ(k)=n. By the induction hypothesis, there exists a permutation π of [n−1] such that ∣ψ′(k)−k∣+1≤π(k), k=1,…,n−1, so ∣ψ(k)−k∣+1≤∣ψ′(k)−k∣+2≤π(k)+1, k=1,…,n−1. Finally, since ∣ψ(n)−n∣+1=1, setting σ(k)=π(k)+1, k=1,…,n−1, and σ(n)=1 defines the required permutation.