{"raw_statement":[{"iden":"statement","content":"You are given a sequence _a_ consisting of _n_ integers. You may partition this sequence into two sequences _b_ and _c_ in such a way that every element belongs exactly to one of these sequences.\n\nLet _B_ be the sum of elements belonging to _b_, and _C_ be the sum of elements belonging to _c_ (if some of these sequences is empty, then its sum is 0). What is the maximum possible value of _B_ - _C_?"},{"iden":"input","content":"The first line contains one integer _n_ (1 ≤ _n_ ≤ 100) — the number of elements in _a_.\n\nThe second line contains _n_ integers _a_1, _a_2, ..., _a__n_ ( - 100 ≤ _a__i_ ≤ 100) — the elements of sequence _a_."},{"iden":"output","content":"Print the maximum possible value of _B_ - _C_, where _B_ is the sum of elements of sequence _b_, and _C_ is the sum of elements of sequence _c_."},{"iden":"examples","content":"Input\n\n3\n1 -2 0\n\nOutput\n\n3\n\nInput\n\n6\n16 23 16 15 42 8\n\nOutput\n\n120"},{"iden":"note","content":"In the first example we may choose _b_ = {1, 0}, _c_ = { - 2}. Then _B_ = 1, _C_ =  - 2, _B_ - _C_ = 3.\n\nIn the second example we choose _b_ = {16, 23, 16, 15, 42, 8}, _c_ = {} (an empty sequence). Then _B_ = 120, _C_ = 0, _B_ - _C_ = 120."}],"translated_statement":[{"iden":"statement","content":"给定一个由 #cf_span[n] 个整数组成的序列 #cf_span[a]。你可以将该序列划分为两个序列 #cf_span[b] 和 #cf_span[c]，使得每个元素恰好属于其中一个序列。\n\n设 #cf_span[B] 为属于 #cf_span[b] 的元素之和，#cf_span[C] 为属于 #cf_span[c] 的元素之和（如果某个序列为空，则其和为 #cf_span[0]）。求 #cf_span[B - C] 的最大可能值？\n\n第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100]) —— 序列 #cf_span[a] 中的元素个数。\n\n第二行包含 #cf_span[n] 个整数 #cf_span[a1], #cf_span[a2], ..., #cf_span[an] (#cf_span[ - 100 ≤ ai ≤ 100]) —— 序列 #cf_span[a] 的元素。\n\n请输出 #cf_span[B - C] 的最大可能值，其中 #cf_span[B] 是序列 #cf_span[b] 的元素之和，#cf_span[C] 是序列 #cf_span[c] 的元素之和。\n\n在第一个例子中，我们可以选择 #cf_span[b = {1, 0}]，#cf_span[c = { - 2}]。此时 #cf_span[B = 1]，#cf_span[C =  - 2]，#cf_span[B - C = 3]。\n\n在第二个例子中，我们选择 #cf_span[b = {16, 23, 16, 15, 42, 8}]，#cf_span[c = {}]（空序列）。此时 #cf_span[B = 120]，#cf_span[C = 0]，#cf_span[B - C = 120]。\n\n"},{"iden":"input","content":"第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100]) —— 序列 #cf_span[a] 中的元素个数。第二行包含 #cf_span[n] 个整数 #cf_span[a1], #cf_span[a2], ..., #cf_span[an] (#cf_span[ - 100 ≤ ai ≤ 100]) —— 序列 #cf_span[a] 的元素。"},{"iden":"output","content":"请输出 #cf_span[B - C] 的最大可能值，其中 #cf_span[B] 是序列 #cf_span[b] 的元素之和，#cf_span[C] 是序列 #cf_span[c] 的元素之和。"},{"iden":"examples","content":"输入31 -2 0输出3输入616 23 16 15 42 8输出120"},{"iden":"note","content":"在第一个例子中，我们可以选择 #cf_span[b = {1, 0}]，#cf_span[c = { - 2}]。此时 #cf_span[B = 1]，#cf_span[C =  - 2]，#cf_span[B - C = 3]。在第二个例子中，我们选择 #cf_span[b = {16, 23, 16, 15, 42, 8}]，#cf_span[c = {}]（空序列）。此时 #cf_span[B = 120]，#cf_span[C = 0]，#cf_span[B - C = 120]。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the number of elements.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of integers, where $ a_i \\in [-100, 100] $.  \n\nLet $ B \\subseteq A $ and $ C = A \\setminus B $ be a partition of $ A $ into two disjoint subsequences (possibly empty).  \nLet $ B = \\sum_{a_i \\in B} a_i $ and $ C = \\sum_{a_i \\in C} a_i $ be the sums of elements in $ B $ and $ C $, respectively.\n\n**Constraints**  \n$ 1 \\leq n \\leq 100 $\n\n**Objective**  \nMaximize $ B - C $, where $ B + C = S = \\sum_{i=1}^n a_i $.  \n\nSince $ B - C = B - (S - B) = 2B - S $, the objective is equivalent to:  \n$$\n\\max_{B \\subseteq A} (2B - S) = 2 \\cdot \\max_{B \\subseteq A} B - S\n$$\n\nThus, the problem reduces to:  \n$$\n\\max_{B \\subseteq A} (2B - S) = 2 \\cdot \\left( \\max_{B \\subseteq A} B \\right) - S\n$$\n\nEquivalently, maximize $ B - C $ by choosing $ B $ to be the subset of $ A $ with maximum possible sum.  \n\n**Final Objective**  \n$$\n\\max_{B \\subseteq A} (B - (S - B)) = \\max_{B \\subseteq A} (2B - S)\n$$","simple_statement":null,"has_page_source":false}