mod = 1000000007 eps = 10**-9 mask = 1023 def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) dp = [[0] * (1 << 10) for _ in range(N+1)] dp_over = [[0] * (1 << 10) for _ in range(N+1)] dp[0][1] = 1 for i, a in enumerate(A): if a: for state in range(1 << 10): # and state_new_and = state & a if dp[i][state] or dp_over[i][state]: dp[i+1][state_new_and] = 1 # add state_new_add = state * a state_new_add_masked = state_new_add & mask if dp[i][state]: if state_new_add != state_new_add_masked: dp_over[i+1][state_new_add_masked] += 1 else: dp[i+1][state_new_add_masked] = 1 dp_over[i+1][state_new_add_masked] += dp_over[i][state] else: dp[i+1][0] = 1 ans = 0 for state in range(1 << 10): ans += dp[i+1][state] + dp_over[i+1][state] print(ans) if __name__ == '__main__': main()