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][0] = 1 for i, a in enumerate(A): for state in range(1 << 10): # and state_new_and = state & a dp[i+1][state_new_and] |= dp[i][state] | dp_over[i][state] # 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] ans = 0 for state in range(1 << 10): ans += dp[i+1][state] + dp_over[i+1][state] print(ans) if __name__ == '__main__': main()