Polycarpus has a sequence, consisting of *n* non-negative integers: *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub>.

Let's define function *f*(*l*, *r*) (*l*, *r* are integer, 1 ≤ *l* ≤ *r* ≤ *n*) for sequence *a* as an operation of bitwise OR of all the sequence elements with indexes from *l* to *r*. Formally: *f*(*l*, *r*) = *a*<sub class="lower-index">*l*</sub> | *a*<sub class="lower-index">*l* + 1</sub> | ...  | *a*<sub class="lower-index">*r*</sub>. 

Polycarpus took a piece of paper and wrote out the values of function *f*(*l*, *r*) for all *l*, *r* (*l*, *r* are integer, 1 ≤ *l* ≤ *r* ≤ *n*). Now he wants to know, how many distinct values he's got in the end. 

Help Polycarpus, count the number of distinct values of function *f*(*l*, *r*) for the given sequence *a*.

Expression *x* | *y* means applying the operation of bitwise OR to numbers *x* and *y*. This operation exists in all modern programming languages, for example, in language C++ and Java it is marked as "|", in Pascal — as "or".
The first line contains integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>) — the number of elements of sequence *a*. The second line contains *n* space-separated integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (0 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">6</sup>) — the elements of sequence *a*.
import sys
import random
import math
from collections import deque
input = sys.stdin.readline
def tt():
    sys.stdout.flush()
def fg():
    return int(input())
def fgh():
    return [int(xx) for xx in input().split()]
def sd():
    print('Yes')
def df():
    print('No')
def sumt(tree, l, r, l1, r1, v):
    m = (l1 + r1) // 2
    if l == l1 and r == r1:
        return tree[v]
    else:
        s = 0
        if l < m:
             s = sumt(tree, l, min(r, m), l1, m, 2 * v + 1) | s
        if r > m:
             s = sumt(tree, max(l, m), r, m, r1, 2 * v + 2) | s
        return s 
def build(a, tree, l, r, v):
    m = (l + r) // 2
    if r - l == 1:
        tree[v] = a[l]
    if r - l > 1:
        build(a, tree, l, m, 2 * v + 1)
        build(a, tree, m, r, 2 * v + 2)
        tree[v] = tree[2 * v + 1] | tree[2 * v + 2]
def main():
    n = fg()
    a = fgh()
    ans = []
    tree = [0] * (4 * n)
    build(a, tree, 0, n, 0)
    for i in range(n):
        for j in range(i + 1, n + 1):
            ans.append(sumt(tree, i, j, 0, n, 0))
    print(len(set(ans)))
main()
