N = int(input()) P = 10 ** 9 + 7 A = [[1,1,1,0],[1,0,0,1],[2,0,1,0],[0,0,0,1]] def seki(X,Y): ans = [[0] * 4 for _ in range(4)] for i in range(4): for j in range(4): for k in range(4): ans[i][j] = (ans[i][j] + X[i][k]*Y[k][j]) % P return ans tmp = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]] u = N-1 while u: if u & 1: tmp = seki(tmp,A) A = seki(A,A) u >>= 1 gn = tmp[0][0] + tmp[0][1] + tmp[0][3] print(gn%P)