n = int(input()) a = list(map(int, input().split())) print(abs(n - a[-1]))