14 lines
216 B
Python
14 lines
216 B
Python
|
import io
|
||
|
import sys
|
||
|
|
||
|
sys.stdin = io.StringIO('''4
|
||
|
2 6 4 1''') # 7
|
||
|
|
||
|
n = int(input())
|
||
|
a = list(map(int, input().split()))
|
||
|
dp0, dp1 = 0, a[0]
|
||
|
for i in range(1, n):
|
||
|
dp0, dp1 = dp1, max(dp1, dp0 + a[i])
|
||
|
|
||
|
print(dp1)
|