#include #include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, i; cin >> N; vector A(N); for (i = 0; i != N; ++i) cin >> A[i]; if (N == 1) { cout << -A[0] << '\n'; return 0; } array cur = { -A[0] + A[1], max(-A[0], -A[1]) }, prev = { INT64_MIN, INT64_MIN }; for (i = 2; i != N; ++i) { prev = cur; if (cur[0] < prev[1] + A[i]) cur[0] = prev[1] + A[i]; if (cur[1] < prev[0] - A[i]) cur[1] = prev[0] - A[i]; if (cur[1] < -A[i]) cur[1] = -A[i]; } cout << max(cur[0], cur[1]) << '\n'; return 0; }