How find this minimum of the value $f(1)+f(2)+\cdots+f(100)$ Give the positive integer set $A=\{1,2,3,\cdots,100\}$, and define function
$f:A\to A$ and 
(1):such for any $1\le i\le 99$,have
$$|f(i)-f(i+1)|\le 1$$
(2): for any $1\le i\le 100$,have $$f(f(i))=100$$
find the minium of the value
$$f(1)+f(2)+f(3)+f(4)+\cdots+f(99)+f(100)$$
maye this is nice problem,and I want use $|f(i)-f(i+1)|\le 1$,But I can't it.Thank you
Now it is said this answer is 8350

Claim: to achieve the minimum, f(n) is a non decreasing function. Suppose not, take the natural construction $f^*(n)$ where we smooth out the decreasing part, show that it satisfies the conditions and has a smaller sum. 
Claim: Suppose that The image of $f(n)$ consists of $k$ elements. Then, because we have a non decreasing function, we see that the minimum sum occurs when we have $f(1)=\ldots=f(100-2k+2)=100-k+1, f(100-2k +j)=100-k+j-1$ for j from 3 to k and $f(100-k+1)=\ldots=f(100)=100$. 
It remains to verify that the minimum sum is achieved at $k=34$  This is easily done n
