N = int(input()) A = list(map(int, input().split())) ans = 0 for l in range(N): for r in range(l, N): for k in range(l, r+1): if k==l: num = A[l] else: num |= A[k] ans += num #print(l, r, A[l]|A[r]) print(ans)