Let $f$ be a function from $\mathbb{N}$ to $\mathbb{N}$ such that
(i) $f(1)=0$
(ii) $f(2n)=2f(n)+1)$
(iii) $f(2x+1)=2f(n)$
Find the least value of $n$ such that $f(n)=2016$.