## https://yukicoder.me/problems/no/3268 def main(): N = int(input()) A = list(map(int, input().split())) a_positive = [] a_negative = [] for a in A: if a >= 0: a_positive.append(a) else: a_negative.append(a) a_negative.sort() a_positive.sort() answer = 0 for i in range(1, len(a_negative)): answer += - a_negative[i - 1] - a_negative[i] p = a_negative[-1] for a in a_positive: answer += a - p p = a answer1 = answer answer2 = float("inf") if len(a_negative) >= 2: answer += a_negative[0] + a_negative[1] answer += -a_negative[0] + a_positive[-1] answer2 = answer answer = min(answer1, answer2) print(answer) if __name__ == '__main__': main()