#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ void Solve() { int n; IN(n); vector a(n); IN(a); ranges::sort(a); int64_t ans = 0; for (int64_t e : a) { ans += 2 * abs(e); } int m = int(ranges::lower_bound(a, 0) - a.begin()); for (int i : Rep(m, n - 1)) { ans -= 2 * a[i]; } ans -= abs(a[0]) + abs(a[1]) + abs(a.back()) - min({abs(a[0]), abs(a[1]), abs(a.back())}); OUT(ans); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); Solve(); } #elif __INCLUDE_LEVEL__ == 1 #include template concept MyRange = std::ranges::range && !std::convertible_to; template concept MyTuple = std::__is_tuple_like::value && !MyRange; namespace std { istream& operator>>(istream& is, MyRange auto&& r) { for (auto&& e : r) is >> e; return is; } istream& operator>>(istream& is, MyTuple auto&& t) { apply([&](auto&... xs) { (is >> ... >> xs); }, t); return is; } ostream& operator<<(ostream& os, MyRange auto&& r) { auto sep = ""; for (auto&& e : r) os << exchange(sep, " ") << e; return os; } ostream& operator<<(ostream& os, MyTuple auto&& t) { auto sep = ""; apply([&](auto&... xs) { ((os << exchange(sep, " ") << xs), ...); }, t); return os; } } // namespace std using namespace std; #define Rep(...) [](int l, int r) { return views::iota(min(l, r), r); }(__VA_ARGS__) #define IN(...) (cin >> forward_as_tuple(__VA_ARGS__)) #define OUT(...) (cout << forward_as_tuple(__VA_ARGS__) << '\n') #endif // __INCLUDE_LEVEL__ == 1