Dynamic programming, coming up with an algorithm
For each $m$, let $\sigma(m)$ be the maximum sum of non-adjacent values among the first $m$ values of the array $A$. Then:
$$
\begin{align*}
&amp;\sigma(0) = 0, \\
&amp;\sigma(1) = A(1), \\
&amp;\sigma(m) = \max(A(m) + \sigma(m-2), \sigma(m-1))
\end{align*}
$$
As an exercise, now try to solve similar problems in which you slightly modify the constraints. For example, suppose that if you select an element then you are not allowed to use $a$ elements before or after it; or that among any $b$ adjacent elements, you are allowed to choose at most $c$.