import numpy as np MOD = 10 ** 9 + 7 def pow_matrix_mod(x, n, mod=MOD): if not n: return np.eye(len(x), dtype=object) if n % 2 == 0: return pow_matrix_mod(x @ x % mod, n // 2) % mod else: return x @ pow_matrix_mod(x @ x % mod, (n - 1) // 2) % mod N = int(input()) X = np.array(list(map(int, input().split())), dtype=object) A = np.array([[1, 0, -1], [-1, 1, 0], [0, -1, 1]], dtype=object) ans = X @ pow_matrix_mod(A, N - 1) % MOD print(*ans)