~/algor $ cat problems/dp-qoshni-bolmagan-uylar
Non-adjacent houses
Easy
1000 ms
128 MB
27%
$n$ houses stand in a row on a street; the owner of the $i$-th house is ready to donate $a_{i}$ soums to charity. A charity picks some of the houses and collects money, but never visits both of two adjacent houses. What is the largest amount that can be collected?
Input
The first line contains a positive integer $n$. The second line contains $n$ space-separated integers $a_{i}$.
Output
One integer — the largest amount that can be collected.
Note
$1 \le n \le 10^{5}$
$0 \le a_{i} \le 10^{9}$
Examples
Input #1
5 2 7 9 3 1
Output #1
12
Input #2
1 0
Output #2
0