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*.
d    = {i:[] for i in range(20)}
used = [False for i in range(1000000)]
n = int(input())
a = list(map(int, input().split()))#[1,22,33,44,15,65]

def search(a, x):
    l  = -1
    u  = len(a)
    
    while u-l>1:
        md = (l+u) // 2
        if x >= a[md]:
            l = md
        else:
            u = md
    return u   

def get_pos(x):
    p_1 = []
    p_0 = []
    
    i = 0
    while x > 0:
        if x % 2 == 1:
            p_1.append(i)
        else:
            p_0.append(i)
            
        x //= 2    
        i+=1    
    
    p_0.extend([x for x in range(i,20)])
    
    return p_1, p_0    

for i, x in enumerate(a):
    p_1, p_0 = get_pos(x)
    for pos in p_1:
        d[pos].append(i)
        
for i, x in enumerate(a):
    p_1, p_0 = get_pos(x)
    used[x]  = True
    
    _d_ = {}
    for p in p_0:
        
        if len(d[p]) > 0:
            next_pos = search(d[p], i)
            
            if next_pos != len(d[p]):
                pos_0 = d[p][next_pos]
                if pos_0 not in _d_:
                    _d_[pos_0] = []
                _d_[pos_0].append(p)
        
    tmp = x
    for v in _d_.values():
        for b in v:
            tmp |= 1 << b 
        used[tmp] = True

l = [x for x in range(1000000) if used[x] == True]
print(len(l))