# Arup Guha
# 12/3/2023
# Solution to 2023 UCF HS Online D2 Problem: First Contact Counting

# Get input
n = int(input())
nums = [int(x) for x in input().split()]

# Do arithmetic sequence formula
print(nums[-1] + (nums[-1] - nums[-2]))
