Let $a_1,$ $a_2,$ $\dots$ be a sequence of real numbers such that for all positive integers $n,$ \[\sum_{k = 1}^n a_k \left( \frac{k}{n} \right)^2 = 1.\]Find the smallest $n$ such that $a_n < \frac{1}{2018}.$
The smallest n such that a_n < 1/2018 is 45.