import sys input = sys.stdin.readline N = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 bias = pow(-3, (N - 2) // 2, mod) shift = ((N - 2) // 2) % 3 if N % 2: res = [(a[i] - a[(i + 1) % 3] * 2 + a[(i + 2) % 3]) * bias % mod for i in range(3)] else: res = [(a[i] - a[(i + 1) % 3]) * bias % mod for i in range(3)] res = res[shift: ] + res[: shift] print(*res)