cswork / OA打开练习工作台

DatabricksOA #16

Difference Between Sums of Positions

估计简单可在线判题

考点(AI 标注)原地数组

Given an array numbers, consider only the elements whose value lies in the closed interval [-100,100]. Compute the sum of such elements at 0-based even indices and the sum at odd indices, and output the former minus the latter.

Standard input/output and this site's supplementary ranges follow this problem's description.

输入格式

The first line contains n (1≤n≤1000), and the second line contains n integers, −1000≤numbers[i]≤1000.

输出格式

Output the filtered even-index sum minus the filtered odd-index sum, as one integer.

样例 1

输入:

6
101 3 4 359 2 5

输出:

-2

样例 2

输入:

6
-2 234 100 99 540 -1

输出:

0

样例 3

输入:

1
-9

输出:

-9