import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n = ni() m = 28 a = na() ans = 0 for j in range(m): f = -1 r = 0 for i in range(n): if a[i] >> j & 1: r += (n-i) * (i - f) f = i ans += r <