0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-24 11:48:48 +00:00
OI-codes/Luogu/T208078/T208078.cpp

22 lines
415 B
C++

#include <bits/stdc++.h>
using namespace std;
long long n, a[100005];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = n; i > 2; i--) {
if (abs(a[i - 1] - a[i]) > abs(a[i - 1] + a[i])) {
a[i - 1] -= a[i];
} else {
a[i - 1] += a[i];
}
}
cout << max(a[1] - a[2], a[1] + a[2]) << endl;
return 0;
}