#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

#define EPS 10e-9
#define INF 0x3f3f3f3f
#define REP(i,n) for(int i=0; i<(n); i++)

int n;
int v[100100];
bool used[1048586];

int main()
{
	scanf("%d", &n);
	REP(i, n)
		scanf("%d", &v[i]);
	memset(used, false, sizeof(used));
	REP(i, n) {
		int x = v[i];
		int j = i-1;
		int y = 0;
		used[x] = true;
		while (1) {
			if (j < 0) break;
			y = y | v[j];
			x = x | v[j];
			if (x == y) break;
			used[x] = true;
			x = x | v[j];
			j--;
		}
	}
	int64 res = 0;
	for (int i = 0; i <= 1048576; i++) {
		if (used[i]) {
			//printf("%d\n", i);
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

#define EPS 10e-9
#define INF 0x3f3f3f3f
#define REP(i,n) for(int i=0; i<(n); i++)

int n;
vector<int> seq[25];
bool used[1048586];
int bits[25];

bool valida(int x) {
	REP(i, 21) {
		if (x & (1 << i) && !bits[i]) return true;
	}
	return false;
}

void adiciona(int x) {
	REP(i, 21) {
		if (x & (1 << i)) bits[i]++;
	}
}

void retira(int x) {
	REP(i, 21) {
		if (x & (1 << i)) bits[i]--;
	}
}

int main()
{
	scanf("%d", &n);
	int ant = -1;
	REP(i, n) {
		int x;
		scanf("%d", &x);
		seq[0].push_back(x);
	}

	for (int i = 1; i <= 20; i++) {
		memset(bits, 0, sizeof(bits));
		//printf("%d:: ", i);
		for (int j = 0; j < n; j++) {
			if (!valida(seq[0][j])) continue;
			seq[i].push_back(seq[0][j]);
			adiciona(seq[0][j]);
			//printf("%d ", seq[0][j]);
			if (seq[i].size() > i) {
				retira(seq[i][seq[i].size() - i - 1]);
			}
		}
		//printf("\n");
	}

	memset(used, false, sizeof(used));
	for (int i = 0; i <= 20; i++) {
		for (int j = 0; j < (int) seq[i].size() - i; j++) {
			int x = 0;
			for (int k = 0; k <= i; k++) {
				x = x | seq[i][j+k];
			}
			used[x] = true;
		}
	}
	int64 res = 0;
	for (int i = 0; i <= 1048576; i++) {
		if (used[i]) {
			//printf("%d\n", i);
			res++;
		}
	}
	//printf("%lld\n", res);1
	cout << res << endl;
	return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

#define EPS 10e-9
#define INF 0x3f3f3f3f
#define REP(i,n) for(int i=0; i<(n); i++)

int n;
vector<int> seq[25];
bool used[1048586];
int bits[25];

bool valida(int x) {
	REP(i, 21) {
		if (x & (1 << i) && !bits[i]) return true;
	}
	return false;
}

void adiciona(int x) {
	REP(i, 21) {
		if (x & (1 << i)) bits[i]++;
	}
}

void retira(int x) {
	REP(i, 21) {
		if (x & (1 << i)) bits[i]--;
	}
}

int main()
{
	scanf("%d", &n);
	int ant = -1;
	REP(i, 21) seq[i].clear();
	REP(i, n) {
		int x;
		scanf("%d", &x);
		seq[0].push_back(x);
	}

	for (int i = 1; i <= 20; i++) {
		memset(bits, 0, sizeof(bits));
		//printf("%d:: ", i);
		for (int j = 0; j < n; j++) {
			if (!valida(seq[0][j])) continue;
			seq[i].push_back(seq[0][j]);
			adiciona(seq[0][j]);
			//printf("%d ", seq[0][j]);
			if ((int) seq[i].size() > i) {
				retira(seq[i][(int) seq[i].size() - i - 1]);
			}
		}
		//printf("\n");
	}

	memset(used, false, sizeof(used));
	for (int i = 0; i <= 20; i++) {
		for (int j = 0; j < (int) seq[i].size() - i; j++) {
			int x = 0;
			for (int k = 0; k <= i; k++) {
				x = x | seq[i][j+k];
			}
			used[x] = true;
		}
	}
	int64 res = 0;
	for (int i = 0; i <= 1048576; i++) {
		if (used[i]) {
			//printf("%d\n", i);
			res++;
		}
	}
	//printf("%lld\n", res);1
	cout << res << endl;
	return 0;
}


#include <cmath>
#include <ctime>
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
#include <stack>
using namespace std;

typedef long long int int64;

#define EPS 10e-9
#define INF 0x3f3f3f3f
#define REP(i,n) for(int i=0; i<(n); i++)

int n;
vector<int> seq[25];
bool used[1048586];
int bits[25];

bool valida(int x) {
	REP(i, 21) {
		if (x & (1 << i) && !bits[i]) return true;
	}
	return false;
}

void adiciona(int x) {
	REP(i, 21) {
		if (x & (1 << i)) bits[i]++;
	}
}

void retira(int x) {
	REP(i, 21) {
		if (x & (1 << i)) bits[i]--;
	}
}

int main()
{
	scanf("%d", &n);
	int ant = -1;
	REP(i, n) {
		int x;
		scanf("%d", &x);
		seq[0].push_back(x);
	}

	for (int i = 1; i <= 20; i++) {
		memset(bits, 0, sizeof(bits));
		//printf("%d:: ", i);
		for (int j = 0; j < n; j++) {
			if (!valida(seq[0][j])) continue;
			seq[i].push_back(seq[0][j]);
			adiciona(seq[0][j]);
			//printf("%d ", seq[0][j]);
			if (seq[i].size() >= i) {
				retira(seq[i][seq[i].size() - i - 1]);
			}
		}
		//printf("\n");
	}

	memset(used, false, sizeof(used));
	for (int i = 0; i <= 20; i++) {
		for (int j = 0; j < (int) seq[i].size() - i; j++) {
			int x = 0;
			for (int k = 0; k <= i; k++) {
				x = x | seq[i][j+k];
			}
			used[x] = true;
		}
	}
	int64 res = 0;
	for (int i = 0; i <= 1048576; i++) {
		if (used[i]) {
			//printf("%d\n", i);
			res++;
		}
	}
	//printf("%lld\n", res);1
	cout << res << endl;
	return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 100010;
int a[maxn << 2], f[maxn << 2];
bool bo[2111111];
int n;

int max_ans;
inline void insert(int x, int l, int r,int p,int q){
    f[x] |= q;
    if (l == r) return;
    int mid = (l + r) >> 1;
    if (p <= mid)
        insert(x << 1, l, mid, p, q);
    else
        insert((x << 1) | 1,mid + 1, r, p, q);
}

inline int ttry(int x, int l, int r, int p, int q){
    if (l == p && r == q) return f[x];
    int mid = (l + r) >> 1;
    if (q <= mid)
        return ttry(x << 1, l, mid, p, q);
    if (p > mid)
        return ttry((x << 1) | 1, mid + 1, r, p, q);
    int t = ttry(x << 1, l, mid, p, mid);
    if (t == max_ans) return t;
    return t | ttry((x << 1) | 1, mid + 1, r, mid + 1, q);
}

inline int find(int x, int l, int r, int p, int ans){
    bo[f[x]] = true;
    if (l == r) return f[x];
    int mid = (l + r) >> 1;
    while (p > mid) return find((x << 1) | 1, mid + 1, r, p, ans);
    if ((ans | f[x]) == ans) return ans;
    int t = ans | find(x << 1, l, mid, p, ans);
    bo[t] = true;
    t |= find((x << 1) + 1, mid + 1, r, p, t);
    bo[t] = true;
    return t;
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        insert(1, 1, n, i, a[i]);
    max_ans = 0;
    for (int i = 1; i <= n; i++) max_ans |= a[i];
//  cerr <<'!' << endl;
    for (int i = 1; i <= n; i++)
    {
    /*  bo[a[i]] = true;
        int now_ans = a[i];
        int now_pos = i;
        while (now_pos != n){
            int l = now_pos;
            int r = n;
            while (l + 1 < r){
                int mid = (l + r) / 2;
                if ((now_ans | ttry(1, 1, n, l, mid)) == now_ans) l = mid; else r = mid;
            }
            now_ans = ttry(1, 1, n, i, r);
            now_pos = r;
            bo[now_ans] = true;
            if (now_ans == max_ans) break;*/
        bo[find(1, 1, n, i, 0)] = true;
    }
    int ans = 0;
    for (int i = 0; i <= 2000000;i++) if (bo[i]) ans++;
    printf("%d\n", ans);

}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 100010;
int a[maxn << 4], f[maxn << 4];
bool bo[2111111];
int n;

void insert(int x, int l, int r,int p,int q){
    f[x] |= q;
    if (l == r) return;
    int mid = (l + r) / 2;
    if (p <= mid)
        insert(2 * x, l, mid, p, q);
    else
        insert(2 * x + 1,mid + 1, r, p, q);
}

int ttry(int x, int l, int r, int p, int q){
    if (l == p && r == q) return f[x];
    int mid = (l + r) / 2;
    if (q <= mid)
        return ttry(x * 2, l, mid, p, q);
    if (p > mid)
        return ttry(x * 2 + 1, mid + 1, r, p, q);
    return ttry( 2 * x, l, mid, p, mid) | ttry(x * 2 + 1, mid + 1, r, mid + 1, q);
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        insert(1, 1, n, i, a[i]);
    int max_ans = 0;
    for (int i = 1; i <= n; i++) max_ans |= a[i];
//  cerr <<'!' << endl;
    for (int i = 1; i <= n; i++)
    {
        bo[a[i]] = true;
        int now_ans = a[i];
        int now_pos = i;
        while (now_pos != n){
            int l = now_pos;
            int r = n;
        //  cerr << l << ' ' << r << endl;
            while (l + 1 < r){
                int mid = (l + r) / 2;
                if (ttry(1, 1, n, i, mid) == now_ans) l = mid; else r = mid;
            }
            now_ans = ttry(1, 1, n, i, r);
    //      cout << i << ' ' << r << ' ' << now_ans << endl;
            now_pos = r;
            bo[now_ans] = true;
            if (now_ans == max_ans) break;
        }
    }
    int ans = 0;
    for (int i = 0; i <= 2000000;i++) if (bo[i]) ans++;
    printf("%d\n", ans);

}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 100010;
int a[maxn << 2], f[maxn << 2];
bool bo[2111111];
int n;

int max_ans;
void insert(int x, int l, int r,int p,int q){
    f[x] |= q;
    if (l == r) return;
    int mid = (l + r) / 2;
    if (p <= mid)
        insert(2 * x, l, mid, p, q);
    else
        insert(2 * x + 1,mid + 1, r, p, q);
}

int ttry(int x, int l, int r, int p, int q){
    if (l == p && r == q) return f[x];
    int mid = (l + r) / 2;
    if (q <= mid)
        return ttry(x * 2, l, mid, p, q);
    if (p > mid)
        return ttry(x * 2 + 1, mid + 1, r, p, q);
    int t = ttry(2 * x, l, mid, p, mid);
    if (t == max_ans) return t;
    return t | ttry(x * 2 + 1, mid + 1, r, mid + 1, q);
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        insert(1, 1, n, i, a[i]);
    max_ans = 0;
    for (int i = 1; i <= n; i++) max_ans |= a[i];
//  cerr <<'!' << endl;
    for (int i = 1; i <= n; i++)
    {
        bo[a[i]] = true;
        int now_ans = a[i];
        int now_pos = i;
        while (now_pos != n){
            int l = now_pos;
            int r = n;
        //  cerr << l << ' ' << r << endl;
            while (l + 1 < r){
                int mid = (l + r) / 2;
                if ((now_ans | ttry(1, 1, n, l, mid)) == now_ans) l = mid; else r = mid;
            }
            now_ans = ttry(1, 1, n, i, r);
    //      cout << i << ' ' << r << ' ' << now_ans << endl;
            now_pos = r;
            bo[now_ans] = true;
            if (now_ans == max_ans) break;
        }
    }
    int ans = 0;
    for (int i = 0; i <= 2000000;i++) if (bo[i]) ans++;
    printf("%d\n", ans);

}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 100010;
int a[maxn << 4], f[maxn << 4];
bool bo[2111111];
int n;

void insert(int x, int l, int r,int p,int q){
    f[x] |= q;
    if (l == r) return;
    int mid = (l + r) / 2;
    if (p <= mid)
        insert(2 * x, l, mid, p, q);
    else
        insert(2 * x + 1,mid + 1, r, p, q);
}

int ttry(int x, int l, int r, int p, int q){
    if (l == p && r == q) return f[x];
    int mid = (l + r) / 2;
    if (q <= mid)
        return ttry(x * 2, l, mid, p, q);
    if (p > mid)
        return ttry(x * 2 + 1, mid + 1, r, p, q);
    return ttry( 2 * x, l, mid, p, mid) | ttry(x * 2 + 1, mid + 1, r, mid + 1, q);
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        insert(1, 1, n, i, a[i]);
//  cerr <<'!' << endl;
    for (int i = 1; i <= n; i++)
    {
        bo[a[i]] = true;
        int now_ans = a[i];
        int now_pos = i;
        while (now_pos != n){
            int l = now_pos;
            int r = n;
        //  cerr << l << ' ' << r << endl;
            while (l + 1 < r){
                int mid = (l + r) / 2;
                if (ttry(1, 1, n, i, mid) == now_ans) l = mid; else r = mid;
            }
            now_ans = ttry(1, 1, n, i, r);
    //      cout << i << ' ' << r << ' ' << now_ans << endl;
            now_pos = r;
            bo[now_ans] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i <= 2000000;i++) if (bo[i]) ans++;
    printf("%d\n", ans);

}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 100010;
int a[maxn << 2], f[maxn << 2];
bool bo[2111111];
int n;

int max_ans;
void insert(int x, int l, int r,int p,int q){
    f[x] |= q;
    if (l == r) return;
    int mid = (l + r) / 2;
    if (p <= mid)
        insert(2 * x, l, mid, p, q);
    else
        insert(2 * x + 1,mid + 1, r, p, q);
}

int ttry(int x, int l, int r, int p, int q){
    if (l == p && r == q) return f[x];
    int mid = (l + r) / 2;
    if (q <= mid)
        return ttry(x * 2, l, mid, p, q);
    if (p > mid)
        return ttry(x * 2 + 1, mid + 1, r, p, q);
    int t = ttry(2 * x, l, mid, p, mid);
    if (t == max_ans) return t;
    return t | ttry(x * 2 + 1, mid + 1, r, mid + 1, q);
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        insert(1, 1, n, i, a[i]);
    max_ans = 0;
    for (int i = 1; i <= n; i++) max_ans |= a[i];
//  cerr <<'!' << endl;
    for (int i = 1; i <= n; i++)
    {
        bo[a[i]] = true;
        int now_ans = a[i];
        int now_pos = i;
        while (now_pos != n){
            int l = now_pos;
            int r = n;
        //  cerr << l << ' ' << r << endl;
            while (l + 1 < r){
                int mid = (l + r) / 2;
                if (ttry(1, 1, n, i, mid) == now_ans) l = mid; else r = mid;
            }
            now_ans = ttry(1, 1, n, i, r);
    //      cout << i << ' ' << r << ' ' << now_ans << endl;
            now_pos = r;
            bo[now_ans] = true;
            if (now_ans == max_ans) break;
        }
    }
    int ans = 0;
    for (int i = 0; i <= 2000000;i++) if (bo[i]) ans++;
    printf("%d\n", ans);

}


#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 100010;
int a[maxn << 2], f[maxn << 2];
bool bo[2111111];
int n;

void insert(int x, int l, int r,int p,int q){
    f[x] |= q;
    if (l == r) return;
    int mid = (l + r) / 2;
    if (p <= mid)
        insert(2 * x, l, mid, p, q);
    else
        insert(2 * x + 1,mid + 1, r, p, q);
}

int ttry(int x, int l, int r, int p, int q){
    if (l == p && r == q) return f[x];
    int mid = (l + r) / 2;
    if (q <= mid)
        return ttry(x * 2, l, mid, p, q);
    if (p > mid)
        return ttry(x * 2 + 1, mid + 1, r, p, q);
    return ttry( 2 * x, l, mid, p, mid) | ttry(x * 2 + 1, mid + 1, r, mid + 1, q);
}
int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++)
        insert(1, 1, n, i, a[i]);
//  cerr <<'!' << endl;
    for (int i = 1; i <= n; i++)
    {
        bo[a[i]] = true;
        int now_ans = a[i];
        int now_pos = i;
        while (now_pos != n){
            int l = now_pos;
            int r = n;
        //  cerr << l << ' ' << r << endl;
            while (l + 1 < r){
                int mid = (l + r) / 2;
                if (ttry(1, 1, n, i, mid) == now_ans) l = mid; else r = mid;
            }
            now_ans = ttry(1, 1, n, i, r);
    //      cout << i << ' ' << r << ' ' << now_ans << endl;
            now_pos = r;
            bo[now_ans] = true;
        }
    }
    int ans = 0;
    for (int i = 0; i <= 2000000;i++) if (bo[i]) ans++;
    printf("%d\n", ans);

}


#include <cstdio>
#include <algorithm>
using namespace std;
const int maxa=1<<20,maxn=1e5 ;
int voj[maxa] ;
int arr[maxn] ;
int main()
{
	int n;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++)
		scanf("%d",arr+i) ;
	int ds ;
	for(int i=1;i<n+1;i++)
	{
		ds=arr[i-1] ;
		int j ;
		for(j=i;j>0 && voj[ds]<j;j--)
			ds|=arr[j-1] ;
		voj[ds]=true ;
		ds=0 ;
		for(int k=i;k>j;k--)
		{
			ds|=arr[k-1] ;
			voj[ds]=max(k,voj[ds])  ;
		}
	//	voj[ds]=true ;

	}
	int ans=0 ;
	for(int i=0;i<maxa;i++)
		ans+=(voj[i]>0) ;
	printf("%d",ans) ;
}


#include <cstdio>
using namespace std;
const int maxa=1<<20,maxn=1e5 ;
bool voj[maxa] ;
int arr[maxn] ;
int main()
{
	int n;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++)
		scanf("%d",arr+i) ;
	int ds ;
	for(int i=0;i<n;i++)
	{
		ds=arr[i] ;
		int j ;
		for(j=i;j>-1 && !voj[ds];j--)
			ds|=arr[j] ;
		voj[ds]=true ;
		ds=0 ;
		for(int k=i;k>j;k--)
		{
			ds|=arr[k] ;
			voj[ds]=true ;
		}
	//	voj[ds]=true ;

	}
	int ans=0 ;
	for(int i=0;i<maxa;i++)
		ans+=voj[i] ;
	printf("%d",ans) ;
}


#include <cstdio>
using namespace std;
const int maxa=1<<14,maxn=1e5 ;
bool voj[maxa] ;
int arr[maxn] ;
int main()
{
	int n;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++)
		scanf("%d",arr+i) ;
	int ds ;
	for(int i=0;i<n;i++)
	{
		ds=arr[i] ;
		int j ;
		for(j=i;j>-1 && !voj[ds];j--)
			ds|=arr[j] ;
		ds=0 ;
		for(int k=i;k>j;k--)
		{
			ds|=arr[k] ;
			voj[ds]=true ;
		}
	}
	int ans=0 ;
	for(int i=0;i<maxa;i++)
		ans+=voj[i] ;
	printf("%d",ans) ;
}


#include <cstdio>
using namespace std;
const int maxa=1<<20,maxn=1e5 ;
bool voj[maxa] ;
int arr[maxn] ;
int main()
{
	int n;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++)
		scanf("%d",arr+i) ;
	int ds ;
	for(int i=0;i<n;i++)
	{
		ds=arr[i] ;
		int j ;
		for(j=i;j>-1 && !voj[ds];j--)
			ds|=arr[j] ;
		voj[ds]=true ;
		ds=0 ;
		for(int k=i;k>j;k--)
		{
			ds|=arr[k] ;
			voj[ds]=true ;
		}
		voj[ds]=true ;

	}
	int ans=0 ;
	for(int i=0;i<maxa;i++)
		ans+=voj[i] ;
	printf("%d",ans) ;
}


#include <cstdio>
#include <algorithm>
using namespace std;
const int maxa=1<<20,maxn=1e5 ;
int voj[maxa] ;
int arr[maxn] ;
int main()
{
	int n;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++)
		scanf("%d",arr+i) ;
	int ds ;
	for(int i=1;i<n+1;i++)
	{
		ds=arr[i-1] ;
		int j ;
		for(j=i;j>0 && voj[ds]<j;j--)
			ds|=arr[j-1] ;
		ds=0 ;
		for(int k=i;k>j;k--)
		{
			ds|=arr[k-1] ;
			voj[ds]=max(k,voj[ds])  ;
		}

	}
	int ans=0 ;
	for(int i=0;i<maxa;i++)
		ans+=(voj[i]>0) ;
	printf("%d",ans) ;
}


#include <cstdio>
using namespace std;
const int maxa=1<<20,maxn=1e5 ;
bool voj[maxa] ;
int arr[maxn] ;
int main()
{
	int n;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++)
		scanf("%d",arr+i) ;
	int ds ;
	for(int i=0;i<n;i++)
	{
		ds=arr[i] ;
		int j ;
		for(j=i;j>-1 && !voj[ds];j--)
			ds|=arr[j] ;
		ds=0 ;
		for(int k=i;k>j;k--)
		{
			ds|=arr[k] ;
			voj[ds]=true ;
		}
	}
	int ans=0 ;
	for(int i=0;i<maxa;i++)
		ans+=voj[i] ;
	printf("%d",ans) ;
}


#include <cstdio>
using namespace std;
const int maxa=1<<21,maxn=1e5 ;
bool voj[maxa] ;
int arr[maxn] ;
int main()
{
	int n;
	scanf("%d",&n) ;
	for(int i=0;i<n;i++)
		scanf("%d",arr+i) ;
	int ds ;
	for(int i=0;i<n;i++)
	{
		ds=arr[i] ;
		int j ;
		for(j=i;j>-1 && !voj[ds];j--)
			ds|=arr[j] ;
		ds=0 ;
		for(int k=i;k>j;k--)
		{
			ds|=arr[k] ;
			voj[ds]=true ;
		}

	}
	int ans=0 ;
	for(int i=0;i<maxa;i++)
		ans+=voj[i] ;
	printf("%d",ans) ;
}


#include <iostream>
using namespace std;
int set [1<<20];

int main ()
{int n,a[100100];
 cin >> n;
 for (int i=0;i<n;i++)
 {cin>>a[i]; set[a[i]]=1;
  int k=0;
  for (int j=i-1;j>=0;j--)
   {k|=a[j];
   //if ((k|a[i])==k) break;
    set [a[i]|k]=1;
   }
}

 int cnt = 0;
 for (int i=0; i<(1<<20);i++) if (set [i]) ++cnt;
 cout<<cnt<<endl;
}


#include <iostream>
using namespace std;
int n,a[100100],set[1000001]={};
int main ()
{ cin>>n;
 for (int i=0;i<n;i++)
 {cin>>a[i]; set[a[i]]=1;
  int k=0;
  for (int j=i-1;j>=0;j--)
   {k|=a[j];
   if ((k|a[i])==k) break;
    set [ a[i]|k ]=1;
   }
}
 int cnt=0;
 for (int i=0; i<(1<<20);i++) if (set [i]) cnt++;
 cout<<cnt<<endl;
}


#include <iostream>
using namespace std;
int set [1<<20];

int main ()
{int n,a[100100];
 cin >> n;
 for (int i=0;i<n;i++)
 {cin>>a[i]; set[a[i]]=1;
  int k=0;
  for (int j=i-1;j>=0;j--)
   {k|=a[j];
   if ((k|a[i])==k) break;
    set [a[i]|k]=1;
   }
}

 int cnt = 0;
 for (int i=0; i<(1<<20);i++) if (set [i]) ++cnt;
 cout<<cnt<<endl;
}


#include <iostream>
using namespace std;
int set[1000001];
int n,a[1000001];
int main ()
{cin>>n;
 for (int i=0;i<n;i++)
 {cin>>a[i]; set[a[i]]=1;
  int k=0;
  for (int j=i-1;j>=0;j--)
   {k|=a[j];
    if ((k|a[i])==k) break;
    set [a[i]|k]=1;
   }
}
 int cnt=0;
 for (int i=0; i<(1<<20);i++) if (set [i]) cnt++;
 cout<<cnt<<endl;
}


#include <iostream>
using namespace std;
int n,a[100100],set[1000001];
int main ()
{ cin>>n;
 for (int i=0;i<n;i++)
 {cin>>a[i]; set[a[i]]=1;
  int k=0;
  for (int j=i-1;j>=0;j--)
   {k|=a[j];
   if ((k|a[i])==k) break;
    set [ a[i]|k ]=1;
   }
}
 int cnt=0;
 for (int i=0; i<(1<<20);i++) if (set [i]) cnt++;
 cout<<cnt<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
set<int> s[2];
int arr[100005];
bool chk[2000001];
int main() {
    long int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    s[0].insert(arr[0]);

    chk[arr[0]]=true;
    int k=1;
    set<int> :: iterator it;
    for(int i=1;i<n;i++){
        s[k].clear();
        for(it=s[1-k].begin();it != s[1-k].end();it++){
            int p=(*it) | arr[i];
            s[k].insert(p);
            chk[p]=true;
        }
        s[k].insert(arr[i]);
        chk[arr[i]]=true;
        k=1-k;
    }
    int ans=0;
    for(int i=0;i<=2000000;i++){
        if(chk[i]==true){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
set<int> s[2];
int arr[100005];
int main() {
    long int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    map<int,int> mp;
    s[0].insert(arr[0]);
    mp[arr[0]]=1;
    int k=1;
    set<int> :: iterator it;
    for(int i=1;i<n;i++){
        s[k].clear();
        for(it=s[1-k].begin();it != s[1-k].end();it++){
            int p=(*it) | arr[i];
            s[k].insert(p);
            mp[p]=1;
        }
        s[k].insert(arr[i]);
        mp[arr[i]]=1;
        k=1-k;
    }
    int ans=0;
    for(int i=0;i<=2000000;i++){
        if(mp[i]==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
set<int> s[2];
int arr[100005];
bool chk[2000000];
int main() {
    long int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    s[0].insert(arr[0]);
    memset(chk,false,sizeof chk);
    chk[arr[0]]=true;
    int k=1;
    set<int> :: iterator it;
    for(int i=1;i<n;i++){
        s[k].clear();
        for(it=s[1-k].begin();it != s[1-k].end();it++){
            int p=(*it) | arr[i];
            s[k].insert(p);
            chk[p]=true;
        }
        s[k].insert(arr[i]);
        chk[arr[i]]=true;
        k=1-k;
    }
    int ans=0;
    for(int i=0;i<=2000000;i++){
        if(chk[i]==true){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
set<int> s[2];
int arr[100005];
bool chk[2000000];
int main() {
    long int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    s[0].insert(arr[0]);
    chk[arr[0]]=true;
    int k=1;
    set<int> :: iterator it;
    for(int i=1;i<n;i++){
        s[k].clear();
        for(it=s[1-k].begin();it != s[1-k].end();it++){
            int p=(*it) | arr[i];
            s[k].insert(p);
            chk[p]=true;
        }
        s[k].insert(arr[i]);
        chk[arr[i]]=true;
        k=1-k;
    }
    int ans=0;
    for(int i=0;i<=2000000;i++){
        if(chk[i]==true){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 2000000
using namespace std;
const lo INF=123123123;
lo d[MN];int nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i];lo now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; op[i] >= (1LL << k); k++)
			{
				if((op[i] & (1LL << k)) == 0) nexi = max(nexi, (lo)nex[now][k]);
			}
			if(nexi ==(lo) -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i =0; i < 30; i++)
		nex[n - 1][i] = INF;
	for(lo i = n - 1; i >= 0; i--)
	{
		if(i != n - 1)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i + 1][j];
			for(lo k = 0; op[i + 1] >= (1LL << k); k++)
			{
				if(op[i + 1] & (1LL << k)) nex[i][k] = i + 1;
			}
		}
		lo cur = op[i];lo now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = INF;
			for(lo k = 0; op[i] >= (1LL << k); k++)
			{
				if((op[i] & (1LL << k)) == 0) nexi = min(nexi, (lo)nex[now][k]);
			}
			if(nexi == INF) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i] > 0) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 1001001
using namespace std;
const lo INF= 2e23;
lo d[MN], nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = (lo)-1;
			for(lo k = 0; k < 30; k++)
			{
				if((cur & (1LL << k)) ==(lo) 0) nexi = max(nexi,(lo) nex[now][k]);
			}
			if(nexi == (lo)-1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 1000001
using namespace std;
const lo INF= 2e23;
lo d[MN], nex[MN][25];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; op[i] >= (1LL << k); k++)
			{
				if(!(op[i] & (1LL << k))) nexi = max(nexi, nex[now][k]);
			}
			if(nexi == -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 2000000
using namespace std;
const lo INF= 2e23;
lo d[MN];short int nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; op[i] >= (1LL << k); k++)
			{
				if(!(op[i] & (1LL << k))) nexi = max(nexi, nex[now][k]);
			}
			if(nexi == -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 1001001
using namespace std;
const lo INF= 2e23;
lo d[MN], nex[MN][25];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 25; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 25; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = (lo)-1;
			for(lo k = 0; cur >= (1LL << k); k++)
			{
				if((cur & (1LL << k)) ==(lo) 0) nexi = max(nexi,(lo) nex[now][k]);
			}
			if(nexi == (lo)-1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 2000000
using namespace std;
const lo INF= 2e23;
lo d[MN], nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; op[i] >= (1LL << k); k++)
			{
				if(!(op[i] & (1LL << k))) nexi = max(nexi, nex[now][k]);
			}
			if(nexi == -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 2001001
using namespace std;
const lo INF= 2e23;
lo d[MN];int nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = (lo)-1;
			for(lo k = 0; k < 30; k++)
			{
				if((cur & (1LL << k)) ==(lo) 0) nexi = max(nexi,(lo) nex[now][k]);
			}
			if(nexi == (lo)-1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 2000000
using namespace std;
const lo INF=123123123;
lo d[MN];int nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		lo cur = 0;
		for(lo j = i ; j >= 0; j--)
		{
			cur = (cur | op[j]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i] > 0) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 1000001
using namespace std;
const lo INF= 2e23;
lo d[MN], nex[MN][25];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; cur >= (1LL << k); k++)
			{
				if(!(cur & (1LL << k))) nexi = max(nexi, nex[now][k]);
			}
			if(nexi == -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 2000000
using namespace std;
const lo INF= 2e23;
lo d[MN];int nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; op[i] >= (1LL << k); k++)
			{
				if(!(op[i] & (1LL << k))) nexi = max(nexi, (lo)nex[now][k]);
			}
			if(nexi == -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 2000000
using namespace std;
const lo INF=123123123;
lo d[MN];int nex[MN][30];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 30; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i];lo now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; cur >= (1LL << k); k++)
			{
				if((cur & (1LL << k)) == 0) nexi = max(nexi, (lo)nex[now][k]);
			}
			if(nexi ==(lo) -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i =0; i < 30; i++)
		nex[n - 1][i] = INF;
	for(lo i = n - 1; i >= 0; i--)
	{
		if(i != n - 1)
		{
		    for(lo j = 0; j < 30; j++)
			     nex[i][j] = nex[i + 1][j];
			for(lo k = 0; op[i + 1] >= (1LL << k); k++)
			{
				if(op[i + 1] & (1LL << k)) nex[i][k] = i + 1;
			}
		}
		lo cur = op[i];lo now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = INF;
			for(lo k = 0; cur >= (1LL << k); k++)
			{
				if((cur & (1LL << k)) == 0) nexi = min(nexi, (lo)nex[now][k]);
			}
			if(nexi == INF) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i] > 0) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 1000001
using namespace std;
const lo INF= 2e23;
lo d[MN], nex[MN][25];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 25; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 25; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = -1;
			for(lo k = 0; cur >= (1LL << k); k++)
			{
				if(!(cur & (1LL << k))) nexi = max(nexi, nex[now][k]);
			}
			if(nexi == -1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#pragma comment(linker, "/STACK:100000000000000")
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string.h>
#include <cctype>
#include <cassert>
#include <ctime>
#define mp make_pair
#define pb push_back
#define lo long long int
#define pi 3.14159265358979323
#define eps 1e-9
#define MN 1001001
using namespace std;
const lo INF= 2e23;
lo d[MN], nex[MN][25];
int main()
{
	//freopen("input.txt", "r", stdin);
	memset(d, 0, sizeof d);
	lo n;
	cin >> n;
	vector<lo> op(n);
	for(lo i = 0; i < n; i++)
		cin >> op[i];
	lo ans = 0;
	for(lo i = 0; i < 25; i++)
		nex[0][i] = -1;
	for(lo i = 0; i < n; i++)
	{
		if(i)
		{
		    for(lo j = 0; j < 25; j++)
			     nex[i][j] = nex[i - 1][j];
			for(lo k = 0; op[i - 1] >= (1LL << k); k++)
			{
				if(op[i - 1] & (1LL << k)) nex[i][k] = i - 1;
			}
		}
		lo cur = op[i], now = i;
		d[cur]++;
		while(true)
		{
			lo nexi = (lo)-1;
			for(lo k = 0; k < 25; k++)
			{
				if((cur & (1LL << k)) ==(lo) 0) nexi = max(nexi,(lo) nex[now][k]);
			}
			if(nexi == (lo)-1) break;
			now = nexi;
			cur = (cur | op[now]);
			d[cur]++;
		}
	}
	for(lo i = 0; i < MN; i++)
	{
		if(d[i]) ans++;
	}
	cout << ans;
}


#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=100005,maxx=1000005;
int n,a[maxn],ans=0;
bool vis[maxn];
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++){
        int x=0;
        if (!vis[a[i]]) {vis[a[i]]=1;ans++;}
        for (int j=i-1;j>=1;j--){
            x=x|a[j];
            if (vis[x|a[i]]==0) {ans++;vis[x|a[i]]=1;}
            if ((x|a[i])==x) break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=100005,maxx=1000005;
int n,a[maxn],ans=0;
bool vis[1<<20];
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++){
        int x=0;
        if (!vis[a[i]]) {vis[a[i]]=1;ans++;}
        for (int j=i-1;j>=1;j--){
            x=x|a[j];
            if (vis[x|a[i]]==0) {ans++;vis[x|a[i]]=1;}
            if ((x|a[i])==x) break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=100005,maxx=1000005;
int n,a[maxn],ans=0;
bool vis[maxx];
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    for (int i=1;i<=n;i++){
        int x=0;
        if (!vis[a[i]]) {vis[a[i]]=1;ans++;}
        for (int j=i-1;j>=1;j--){
            x=x|a[j];
            if (vis[x|a[i]]==0) {ans++;vis[x|a[i]]=1;}
            if ((x|a[i])==x) break;
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = (n) - 1; i > -1; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define inf 2147483647
#define F first
#define S second
#define N 1100000

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int mb = 20;
char used[N];
int b[mb], a[N / 10], n;

int main()
{
#ifdef LocalHost
    freopen("in", "r", stdin);
//    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    Forn(i, n) scanf("%d", &a[i]);
    fill(b, 0);
    Forn(i, mb)
    {
        while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
    }
    fill(used, 0);
    Forn(e, n)
    {
        int x = a[e], z = e;
        used[x] = 1;
        while (1)
        {
            z = n;
            Forn(i, mb)
                if (!(x & (1 << i)))
                    z = min(z, b[i]);
            if (z == n)
                break;
            Forn(i, mb)
                if (z == b[i])
                {
                    x |= 1 << i;
                }
            used[x] = 1;
        }
        Forn(i, mb)
        {
            if (b[i] == e)
                b[i]++;
            while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
        }
    }
    int ans = 0;
    Forn(i, N)
        ans += used[i];
    printf("%d\n", ans);
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = (n) - 1; i > -1; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define inf 2147483647
#define F first
#define S second
#define N 1100000

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int mb = 20;
char used[N];
int b[mb], a[N / 10], n;

int main()
{
#ifdef LocalHost
    freopen("in", "r", stdin);
//    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    Forn(i, n) scanf("%d", &a[i]);
    fill(b, 0);
    Forn(i, mb)
    {
        while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
    }
    fill(used, 0);
    Forn(e, n)
    {
        int x = a[e], z = e;
        used[x] = 1;
        while (1)
        {
            z = n;
            Forn(i, mb)
                if (!(x & (1 << i)))
                    z = min(z, b[i]);
            if (z == n)
                break;
            Forn(i, mb)
                if (z == b[i])
                {
                    x |= 1 << i;
                    used[x] = 1;
                }
        }
        Forn(i, mb)
        {
            if (b[i] == e)
                b[i]++;
            while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
        }
    }
    int ans = 0;
    Forn(i, N)
        ans += used[i];
    printf("%d\n", ans);
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = (n) - 1; i > -1; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define inf 2147483647
#define F first
#define S second
#define N 1100000

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int mb = 20;
char used[N];
int b[mb], a[N / 10], n;

int main()
{
#ifdef LocalHost
    freopen("in", "r", stdin);
//    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    Forn(i, n) scanf("%d", &a[i]);
    fill(b, 0);
    Forn(i, mb)
    {
        while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
    }
    Forn(e, n)
    {
        int x = a[e], z = e;
        used[x] = 1;
        while (1)
        {
            z = n;
            Forn(i, mb)
                if (!(x & (1 << i)))
                    z = min(z, b[i]);
            if (z == n)
                break;
            Forn(i, mb)
                if (z == b[i])
                {
                    x |= 1 << i;
                    used[x] = 1;
                }
        }
        Forn(i, mb)
        {
            if (b[i] == e)
                b[i]++;
            while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
        }
    }
    int ans = 0;
    Forn(i, N)
        ans += used[i];
    printf("%d\n", ans);
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <memory.h>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define Forn(i, n) for (int i = 0; i < (n); i++)
#define Fornr(i, n) for (int i = (n) - 1; i > -1; i--)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define Forr(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define fill(a, b) memset((a), (b), sizeof((a)))
#define pb push_back
#define inf 2147483647
#define F first
#define S second
#define N 1100000

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int mb = 21;
char used[N];
int b[mb], a[N / 10], n;

int main()
{
#ifdef LocalHost
    freopen("in", "r", stdin);
//    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    Forn(i, n) scanf("%d", &a[i]);
    fill(b, 0);
    Forn(i, mb)
    {
        while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
    }
    Forn(e, n)
    {
        int x = a[e], z = e;
        used[x] = 1;
        while (1)
        {
            z = n;
            Forn(i, mb)
                if (!(x & (1 << i)))
                    z = min(z, b[i]);
            if (z == n)
                break;
            Forn(i, mb)
                if (z == b[i])
                {
                    x |= 1 << i;
                    used[x] = 1;
                }
        }
        Forn(i, mb)
        {
            if (b[i] == e)
                b[i]++;
            while (b[i] != n && !(a[b[i]] & (1 << i))) b[i]++;
        }
    }
    int ans = 0;
    Forn(i, N)
        ans += used[i];
    printf("%d\n", ans);
}


// In the name of ALLAH

#include <iostream>
#include <cstring>

using namespace std ;

const int N=100000+10 ;

int x,n,a[N],last[20+5] ;
bool b[10*N] ;

int main ()
{
	memset(b,0,sizeof(b)) ;
	memset(last,-1,sizeof(last)) ;
	cin>>n ;
	for (int i=0;i<n;i++)
	{
		cin>>a[i] ;
		b[a[i]]=1 ;
		for (int j=0;j<20;j++)
			if ( (a[i]&(1<<j))>0 )
			{
				x=0 ;
				//cerr<<j<<"  "<<last[j]<<endl ;
				for (int k=i;k>last[j];k--)
				{
					x=x|a[k] ;
					b[x]=1 ;
				}
				last[j]=i ;
			}
	}

	int ans=0 ;
	for (int i=0;i<10*N;i++)
		if ( b[i] )
		{
			//cerr<<i<<endl ;
			ans++ ;
		}
	cout<<ans<<'\n' ;

	return 0 ;
}


// In the name of ALLAH

#include <iostream>
#include <cstring>

using namespace std ;

const int N=100000+10 ;

int x,n,a[N],last[20+5] ;
bool b[20*N] ;

int main ()
{
    memset(b,0,sizeof(b)) ;
    memset(last,-1,sizeof(last)) ;
    cin>>n ;
    for (int i=0;i<n;i++)
    {
        cin>>a[i] ;
        b[a[i]]=1 ;
        for (int j=0;j<=20;j++)
            if ( (a[i]&(1<<j)) )
            {
                //cerr<<j<<"  "<<last[j]<<endl ;
                for (int k=i;k>last[j];k--)
                {
                    x|=a[k] ;
                    b[x]=1 ;
                }
                last[j]=i ;
                x=0 ;
            }
    }

    int ans=0 ;
    for (int i=0;i<20*N;i++)
        if ( b[i] )
        {
            //cerr<<i<<endl ;
            ans++ ;
        }
    cout<<ans<<'\n' ;

    return 0 ;
}


// In the name of ALLAH

#include <iostream>
#include <cstring>

using namespace std ;

const int N=100000+10 ;

int x,n,a[N],last[20+5] ;
bool b[20*N] ;

int main ()
{
	memset(b,0,sizeof(b)) ;
	memset(last,-1,sizeof(last)) ;
	cin>>n ;
	for (int i=0;i<n;i++)
	{
		cin>>a[i] ;
		b[a[i]]=1 ;
		for (int j=0;j<=20;j++)
			if ( (a[i]&(1<<j)) )
			{
				x=0 ;
				//cerr<<j<<"  "<<last[j]<<endl ;
				for (int k=i;k>last[j];k--)
				{
					x=x|a[k] ;
					b[x]=1 ;
				}
				last[j]=i ;
			}
	}

	int ans=0 ;
	for (int i=0;i<10*N;i++)
		if ( b[i] )
		{
			//cerr<<i<<endl ;
			ans++ ;
		}
	cout<<ans<<'\n' ;

	return 0 ;
}


// In the name of ALLAH

#include <iostream>
#include <cstring>

using namespace std ;

const int N=100000+10 ;

int x,n,a[N],last[20+5] ;
bool b[20*N] ;

int main ()
{
    memset(b,0,sizeof(b)) ;
    memset(last,0,sizeof(last)) ;
    cin>>n ;
    for (int i=0;i<n;i++)
    {
        cin>>a[i] ;
        b[a[i]]=1 ;
        for (int j=0;j<=20;j++)
            if ( (a[i]&(1<<j)) )
            {
                //cerr<<j<<"  "<<last[j]<<endl ;
                for (int k=i;k>last[j];k--)
                {
                    x|=a[k] ;
                    b[x]=1 ;
                }
                last[j]=i ;
                x=0 ;
            }
    }

    int ans=0 ;
    for (int i=0;i<10*N;i++)
        if ( b[i] )
        {
            //cerr<<i<<endl ;
            ans++ ;
        }
    cout<<ans<<'\n' ;

    return 0 ;
}


// In the name of ALLAH

#include <iostream>
#include <cstring>

using namespace std ;

const int N=100000+10 ;

int x,n,a[N],last[20+5] ;
bool b[20*N] ;

int main ()
{
    memset(b,0,sizeof(b)) ;
    memset(last,-1,sizeof(last)) ;
    cin>>n ;
    for (int i=0;i<n;i++)
    {
        cin>>a[i] ;
        b[a[i]]=1 ;
        for (int j=0;j<=20;j++)
            if ( (a[i]&(1<<j)) )
            {
                //cerr<<j<<"  "<<last[j]<<endl ;
                for (int k=i;k>last[j];k--)
                {
                    x|=a[k] ;
                    b[x]=1 ;
                }
                last[j]=i ;
                x=0 ;
            }
    }

    int ans=0 ;
    for (int i=0;i<10*N;i++)
        if ( b[i] )
        {
            //cerr<<i<<endl ;
            ans++ ;
        }
    cout<<ans<<'\n' ;

    return 0 ;
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <set>
#include<vector>
using namespace std;
vector<vector<int> > table;
int val[100005];
int n;
set<int> unique;

void solve() {
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            tmp = (table[i][j - i - 1] | val[j]);
            table[i][j - i] = tmp;
            unique.insert(table[i][j - i]);
        }
    }
    printf("%lu\n", unique.size());
}

int main(int argc, char **argv) {

    scanf("%d", &n);
    int t;
    table.assign(n, vector<int>());
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        table[i].assign(n - i, 0);
        table[i][0] = t;
        unique.insert(table[i][0]);
        val[i] = t;
    }
    solve();
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <vector>
#include <set>
using namespace std;
int table[100005];
int val[100005];
int unique[1 << 20];
int n;
int cnt;

int main(int argc, char **argv) {
	int t, tmp;
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &t);
		for (int j = i - 1; j >= 1; --j) {
			if (table[j] != table[j] | t) {
				table[j] = table[j] | t;
				if (unique[table[j]] == 0) {
					cnt++;
					unique[table[j]] = 1;
				}
			} else
				break;
		}
		table[i] = t;
		if (unique[table[i]] == 0) {
			cnt++;
			unique[table[i]] = 1;
		}
	}
	printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <vector>
using namespace std;
int table[100005][2];
int val[100005];
int unique[1000005];
int n;
int cnt;

int main(int argc, char **argv) {
    int t, tmp;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        table[i][0] = t;
        val[i] = t;
    }
    for (int i = 0; i < n; ++i) {
        if (unique[table[i][0]] == 0 || unique[table[i][0]] > i ) {
            if (unique[table[i][0]] == 0) {
                cnt++;
                unique[table[i][0]] = 1;
            }
            for (int j = i + 1; j < n; ++j) {
                tmp = (table[i][0] | val[j]);
                table[i][1] = tmp;
                if (unique[tmp] == 0) {
                    unique[tmp] = j;
                    cnt++;
                }
                swap(table[i][0], table[i][1]);
            }
        }
    }
    printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <vector>
using namespace std;
int table[100005][2];
int val[100005];
int unique[1000005];
int n;
int cnt;

int main(int argc, char **argv) {
    int t, tmp;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        table[i][0] = t;
        val[i] = t;
        if (unique[t] == 0) {
            cnt++;
            unique[t] = 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            tmp = (table[i][0] | val[j]);
            table[i][1] = tmp;
            if (unique[tmp] == 0) {
                unique[tmp] = 1;
                cnt++;
            }
            swap(table[i][0], table[i][1]);
        }
    }
    printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
using namespace std;
int table[100005];
int unique[1 << 20];
int n, t, cnt;

int main(int argc, char **argv) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &t);
        for (int j = i - 1; j >= 1; --j) {
            if (table[j] != (table[j] | t))
                unique[table[j] = table[j] | t] = 1;
            else
                break;
        }
        unique[table[i] = t] = 1;
    }
    for (int i = 0; i < (1 << 20); ++i) {
        if (unique[i] == 1) {
            cnt++;
        }
    }
    printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <vector>
#include <set>
using namespace std;
int table[100005];
int val[100005];
int unique[1 << 20];
int n;
int cnt;

int main(int argc, char **argv) {
    int t, tmp;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &t);
        for (int j = i - 1; j >= 1; --j) {
            if (table[j] != table[j] | t) {
                table[j] = table[j] | t;
                unique[table[j]] = 1;
            } else
                break;
        }
        table[i] = t;
        unique[table[i]] = 1;
    }
    for (int i = 0; i < (1 << 20); ++i) {
        if (unique[i])
            cnt++;
    }
    printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <set>
#include<vector>
using namespace std;
int table[100005][3];
int val[100005];
int unique[1000005];
int n;
int cnt;
void solve() {
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            tmp = (table[i][0] | val[j]);
            table[i][1] = tmp;
            if (unique[tmp] == 0) {
                unique[tmp] = 1;
                cnt++;
            }
            swap(table[i][0], table[i][1]);
        }
    }
    printf("%d\n", cnt);
}

int main(int argc, char **argv) {

    scanf("%d", &n);
    int t;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        table[i][0] = t;
        val[i] = t;
        if (unique[t] == 0) {
            cnt++;
            unique[t] = 1;
        }
    }
    solve();
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <set>
#include<vector>
using namespace std;
int table[100005][3];
int val[100005];
int n;
set<int> unique;

void solve() {
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            tmp = (table[i][0] | val[j]);
            table[i][1] = tmp;
            unique.insert(table[i][1]);
            swap(table[i][0], table[i][1]);
        }
    }
    printf("%lu\n", unique.size());
}

int main(int argc, char **argv) {

    scanf("%d", &n);
    int t;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        table[i][0] = t;
        unique.insert(table[i][0]);
        val[i] = t;
    }
    solve();
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
using namespace std;
int table[100005];
int unique[1 << 20];
int n, t, cnt;

int main(int argc, char **argv) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &t);
        for (int j = i - 1; j >= 1; --j) {
            if (table[j] != (table[j] | t))
                unique[table[j] = table[j] | t] = 1;
            else
                break;
        }
        unique[table[i] = t] = 1;
    }
    for (int i = 0; i < (1 << 20); ++i) {
        if (unique[i] == 1) {
            cnt++;
        }
    }

    printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <vector>
using namespace std;
int table[100005][2];
int val[100005];
int unique[1000005];
int n;
int cnt;

int main(int argc, char **argv) {
    int t, tmp;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        table[i][0] = t;
        val[i] = t;
    }
    for (int i = 0; i < n; ++i) {
        if (unique[table[i][0]] == 0) {
            if (unique[table[i][0]] == 0) {
                cnt++;
                unique[table[i][0]] = 1;
            }
            for (int j = i + 1; j < n; ++j) {
                tmp = (table[i][0] | val[j]);
                table[i][1] = tmp;
                if (unique[tmp] == 0) {
                    unique[tmp] = 1;
                    cnt++;
                }
                swap(table[i][0], table[i][1]);
            }
        }
    }
    printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <set>
#include<vector>
using namespace std;
int table[100005][3];
int val[100005];
int unique[1000005];
int n;
int cnt;
void solve() {
    int tmp = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            tmp = (table[i][0] | val[j]);
            table[i][1] = tmp;
            if (unique[tmp] == 0) {
                unique[table[i][1]] = tmp;
                cnt++;
            }
            swap(table[i][0], table[i][1]);
        }
    }
    printf("%d\n", cnt);
}

int main(int argc, char **argv) {

    scanf("%d", &n);
    int t;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        table[i][0] = t;
        val[i] = t;
        if (unique[t] == 0) {
            cnt++;
            unique[t] = t;
        }
    }
    solve();
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
using namespace std;
int table[100005];
int unique[1 << 20];
int n, t, cnt;

int main(int argc, char **argv) {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &t);
        for (int j = i - 1; j >= 1; --j) {
            if (table[j] != (table[j] | t))
                unique[table[j] = table[j] | t] = 1;
            else
                break;
        }
        unique[table[i] = t] = 1;
    }
    for (int i = 0; i < (i << 20); ++i) {
        if (unique[i])
            cnt++;
    }
    printf("%d\n", cnt);
}


/*
 * TheBrandNewFunction.cpp
 *
 *  Created on: Sep 10, 2013
 *      Author: mohamed
 */

#include <stdio.h>
#include <vector>
#include <set>
using namespace std;
int table[100005];
int val[100005];
set<int> unique;
int n;
int cnt;

int main(int argc, char **argv) {
    int t, tmp;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &t);
        for (int j = i - 1; j >= 1; --j) {
            if (table[j] != table[j] | t) {
                table[j] = table[j] | t;
                unique.insert(table[j]);
            } else
                break;
        }
        table[i] = t;
        unique.insert(t);
    }
    printf("%lu\n", unique.size());
}


#include <iostream>
#include <cstdio>

using namespace std;

int a, f[100005], fg[1<<20], n, cnt=0;
int main()
{
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d", &a);
        for(int j=i-1; j>=1; j--)
            if(f[j]!=(f[j]|a)) fg[f[j]=f[j]|a]=1;
            else break;
        fg[f[i]=a]=1;
    }
    for(int i=0; i<(1<<20); i++)
        if(fg[i]) cnt++;
    printf("%d\n", cnt);
}


#include <cstdio>

using namespace std;

struct Tree
{
    int st, ed;
    int val;
    Tree *l, *r;
} pool[50000];

Tree *newTree(int st, int ed)
{
    static int p = 0;
    pool[p].st = st; pool[p].ed = ed;
    pool[p].val = 0;
    pool[p].l = pool[p].r = NULL;
    return &pool[p++];
}

void makeTree(Tree *t)
{
    if(t->st==t->ed) return;
    int mid = (t->st+t->ed) / 2;
    t->l = newTree(t->st, mid);
    makeTree(t->l);
    t->r = newTree(mid+1, t->ed);
    makeTree(t->r);
}

void insert(Tree *t, int pos, int k)
{
    if(t==NULL) return;
    t->val |= k;
    int mid = (t->st+t->ed) / 2;
    if(pos<=mid) insert(t->l, pos, k);
    else insert(t->r, pos, k);
}

bool vis[2000000];
int cnt;
void dfs(Tree *t)
{
    if(t==NULL) return;
    if(!vis[t->val]){ cnt++; vis[t->val] = true; }
    dfs(t->l); dfs(t->r);
}

int main()
{
    int n;
    scanf("%d", &n);
    Tree *t = newTree(1, n);
    makeTree(t);
    for(int i=1; i<=n; i++)
    {
        int k;
        scanf("%d", &k);
        insert(t, i, k);
    }
    dfs(t);
    printf("%d\n", cnt);
    return 0;
}


#include <cstdio>

using namespace std;

int a[100010], k[100010];
bool vis[2000000];

int main()
{
    freopen("in.txt", "r", stdin);
    int n;
    scanf("%d", &n);
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
        k[i] = k[i-1] | a[i];
        int x = 0;
        for(int j=i; j>=1; j--)
        {
            x |= a[j];
            if(!vis[x]){ ans++; vis[x] = true; }
            if(x==k[j]) break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <cstdio>

using namespace std;

int a[100010], k[100010];
bool vis[2000000];

int main()
{
    int n;
    scanf("%d", &n);
    int ans = 0;
    for(int i=1; i<=n; i++)
    {
        scanf("%d", &a[i]);
        k[i] = k[i-1] | a[i];
        int x = 0;
        for(int j=i; j>=1; j--)
        {
            x |= a[j];
            if(!vis[x]){ ans++; vis[x] = true; }
            if(x==k[j]) break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <functional>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef unsigned long long ullong;
typedef long long llong;
typedef list<int> EdgeList;
typedef vector<EdgeList> AdjList;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define FOR_EDGE(adj,v,it) for (EdgeList::iterator it = adj[v].begin(); \
    it != adj[v].end(); ++it)

int main() {
  setvbuf(stdin, NULL, _IOFBF, 10000);
  setvbuf(stdout, NULL, _IOFBF, 10000);

  int n;
  scanf("%d", &n);
  int arr[102400];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
  }
  bool marked[2124000];
  int prev[102400];
  prev[0] = arr[0];
  int stop = -1;
  memset(marked, 0, sizeof(marked));
  marked[arr[0]] = true;
  for (int i = 1; i < n; ++i) {
    int x = arr[i];
    prev[i] = x;
    marked[x] = true;
    for (int j = i-1; j > stop; --j) {
      x |= arr[j];
      prev[j] = x;
      marked[x] = true;
      if (x == prev[j]) {
        stop = j-1;
        break;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < 2124000; ++i) {
    if (marked[i]) ++cnt;
  }
  printf("%d\n", cnt);

  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <functional>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef unsigned long long ullong;
typedef long long llong;
typedef list<int> EdgeList;
typedef vector<EdgeList> AdjList;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define FOR_EDGE(adj,v,it) for (EdgeList::iterator it = adj[v].begin(); \
    it != adj[v].end(); ++it)

int main() {
  setvbuf(stdin, NULL, _IOFBF, 10000);
  setvbuf(stdout, NULL, _IOFBF, 10000);

  int n;
  scanf("%d", &n);
  int arr[102400];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
  }
  bool marked[2124000];
  int prev[102400];
  prev[0] = arr[0];
  int stop = -1;
  memset(marked, 0, sizeof(marked));
  marked[arr[0]] = true;
  for (int i = 1; i < n; ++i) {
    int x = arr[i];
    prev[i] = x;
    marked[x] = true;
    for (int j = i-1; j >= 0; --j) {
      x |= arr[j];
      marked[x] = true;
      if (x == prev[j]) {
        prev[j] = x;
        break;
      }
      prev[j] = x;
    }
  }
  int cnt = 0;
  for (int i = 0; i < 2124000; ++i) {
    if (marked[i]) ++cnt;
  }
  printf("%d\n", cnt);

  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <functional>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef unsigned long long ullong;
typedef long long llong;
typedef list<int> EdgeList;
typedef vector<EdgeList> AdjList;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define FOR_EDGE(adj,v,it) for (EdgeList::iterator it = adj[v].begin(); \
    it != adj[v].end(); ++it)

int main() {
  setvbuf(stdin, NULL, _IOFBF, 10000);
  setvbuf(stdout, NULL, _IOFBF, 10000);

  int n;
  scanf("%d", &n);
  int arr[102400];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
  }
  if (n == 1) {
    puts("1");
  }
  bool marked[2024000];
  int prev[102400];
  prev[0] = arr[0];
  int stop = -1;
  memset(marked, 0, sizeof(marked));
  marked[arr[0]] = true;
  for (int i = 1; i < n; ++i) {
    int x = arr[i];
    marked[x] = true;
    for (int j = i-1; j > stop; --j) {
      x |= arr[j];
      marked[x] = true;
      if (x == prev[j]) {
        stop = j-1;
        break;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < 2024000; ++i) {
    if (marked[i]) ++cnt;
  }
  printf("%d\n", cnt);

  return 0;
}


#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <functional>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef unsigned long long ullong;
typedef long long llong;
typedef list<int> EdgeList;
typedef vector<EdgeList> AdjList;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define FOR_EDGE(adj,v,it) for (EdgeList::iterator it = adj[v].begin(); \
    it != adj[v].end(); ++it)

int main() {
  setvbuf(stdin, NULL, _IOFBF, 10000);
  setvbuf(stdout, NULL, _IOFBF, 10000);

  int n;
  scanf("%d", &n);
  int arr[102400];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &arr[i]);
  }
  bool marked[2124000];
  int prev[102400];
  prev[0] = arr[0];
  int stop = -1;
  memset(marked, 0, sizeof(marked));
  marked[arr[0]] = true;
  for (int i = 1; i < n; ++i) {
    int x = arr[i];
    prev[i] = x;
    marked[x] = true;
    for (int j = i-1; j > stop; --j) {
      x |= arr[j];
      marked[x] = true;
      if (x == prev[j]) {
        stop = j-1;
        prev[j] = x;
        break;
      }
      prev[j] = x;
    }
  }
  int cnt = 0;
  for (int i = 0; i < 2124000; ++i) {
    if (marked[i]) ++cnt;
  }
  printf("%d\n", cnt);

  return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std ;
const int maxn = 100010 ;
const int inf  = (1<<20) + 100 ;
int a[maxn] ;
int a_pos[32] ;
int b_pos[maxn] ;
int vis[inf] ;
int solve(int n ,int pos)
{
    int t = 0;
    for(int i = 0;i <=20 ;i++)
    {
       // cout<<a_pos[i]<<" ";
        if(((n&(1<<i)) == 0)&&(a_pos[i]!=0))
        {
            b_pos[t++] = a_pos[i] ;
            //cout<<"21"<<endl;
        }
        else if((n&(1<<i))) a_pos[i] = pos ;
    }
    return t ;
}
int main()
{
 //  freopen("input.txt" ,"r",stdin);
    int n ;
    while(~scanf("%d" ,&n))
    {
        memset(vis , 0  , sizeof(vis)) ;
        memset(a_pos , 0  ,sizeof(a_pos)) ;
        for(int i = 1;i <= n;i++)
        {
            scanf("%d" ,&a[i]) ;
            int sum = solve(a[i] , i);
            //cout<<sum<<endl;
            sort(b_pos , b_pos+sum) ;
            int t = a[i] ;vis[t] = 1;
            for(int j = 0;j < sum;j++)
            t|=a[b_pos[j]] , vis[t] = 1 ;
        }
       /* for(int i = 0;i <= 20 ;i++)
        printf("%d%c" , a_pos[i] ,i == 20?'\n':' ');*/
        int ans = 0 ;
        for(int i = 0;i < inf ;i++)
        if(vis[i])
        {ans++ ;
        // cout<<i<<endl;
        }
        //puts("") ;
        printf("%d\n" ,ans) ;
     }
     return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std ;
const int maxn = 100010 ;
const int inf  = (1<<20) + 100 ;
int a[maxn] ;
int a_pos[32] ;
int b_pos[maxn] ;
int vis[inf] ;
int solve(int n ,int pos)
{
    int t = 0;
    for(int i = 0;i <=20 ;i++)
    {
       // cout<<a_pos[i]<<" ";
        if(((n&(1<<i)) == 0)&&(a_pos[i]!=0))
        {
            b_pos[t++] = a_pos[i] ;
            //cout<<"21"<<endl;
        }
        else if((n&(1<<i))) a_pos[i] = pos ;
    }
    return t ;
}
int main()
{
   //freopen("input.txt" ,"r",stdin);
    int n ;
    while(~scanf("%d" ,&n))
    {
        memset(vis , 0  , sizeof(vis)) ;
        memset(a_pos , 0  ,sizeof(a_pos)) ;
        for(int i = 1;i <= n;i++)
        {
            scanf("%d" ,&a[i]) ;
            int sum = solve(a[i] , i);
           // cout<<sum;
            if(sum!=0)
            sort(b_pos , b_pos+sum) ;
            //for(int j =0;j < sum ; j++)
            //printf(" %d" , b_pos[j]) ;
          //  cout<<endl;
            int t = a[i] ;vis[t] = 1;
            for(int j = sum - 1;j >= 0;j--)
            t|=a[b_pos[j]] , vis[t] = 1 ;
        }
       /* for(int i = 0;i <= 20 ;i++)
        printf("%d%c" , a_pos[i] ,i == 20?'\n':' ');*/
        int ans = 0 ;
        for(int i = 0;i < inf ;i++)
        if(vis[i])
        {ans++ ;
         //cout<<i<<endl;
        }
        //puts("") ;
        printf("%d\n" ,ans) ;
     }
     return 0;
}


//开一个数组存入当前位置二进制位每一位的最后一个位置
//处理到第i位时，让第i位数与前面的每一位的最后一位置从大到小取或
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std ;
const int maxn = 100010 ;
const int inf  = (1<<20) + 100 ;
int a[maxn] ;
int a_pos[32] ;
int b_pos[maxn] ;
int vis[inf] ;
int solve(int n ,int pos)
{
    int t = 0;
    for(int i = 0;i <=20 ;i++)
    {
        if(((n&(1<<i)) == 0)&&(a_pos[i]!=0))
            b_pos[t++] = a_pos[i] ;
        else if((n&(1<<i))) a_pos[i] = pos ;
    }
    return t ;
}
int main()
{
   //freopen("input.txt" ,"r",stdin);
    int n ;
    while(~scanf("%d" ,&n))
    {
        memset(vis , 0  , sizeof(vis)) ;
        memset(a_pos , 0  ,sizeof(a_pos)) ;
        for(int i = 1;i <= n;i++)
        {
            scanf("%d" ,&a[i]) ;
            int sum = solve(a[i] , i);
            if(sum!=0)
            sort(b_pos , b_pos+sum) ;
            int t = a[i] ;vis[t] = 1;
            for(int j = sum - 1;j >= 0;j--)
            t|=a[b_pos[j]] , vis[t] = 1 ;
        }
        int ans = 0 ;
        for(int i = 0;i < inf ;i++)
        if(vis[i])
        ans++ ;
        printf("%d\n" ,ans) ;
     }
     return 0;
}


#include<algorithm>
#include<cassert>
#include<complex>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>
#include<string>
#include<vector>
#include<iostream>
#include<cstring>
#include<stack>
#include<iostream>
#include<iomanip>

#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define fup FOR
#define fdo FORD
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define siz SZ
#define CLR(x) memset((x), 0, sizeof(x))
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define FI X
#define SE Y
#define SQR(a) ((a)*(a))
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FORE(it, (x)) cerr <<*it <<", "; cout <<endl; }}
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int>P;
typedef vector<int>VI;
const int INF=1E9+7;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }

int main() {

    int n;
    int arr[100100];
    set <int> nom;

    cin >> n;

    for(int i=0;i<n;++i)
        cin >> arr[i];

    nom.insert(arr[0]);

    for(int i=1;i<n;++i) {
        nom.insert(arr[i]);
        for (set<int>::iterator it=nom.begin(); it!=nom.end(); ++it) {
             nom.insert(*it | arr[i]);
             // cout << (*it | arr[i]) << endl;
         }
         nom.erase(arr[i-1]);
    }

    for(int i=0;i<n;i++)
        nom.insert(arr[i]);

    cout << nom.size() << endl;
}


#include<algorithm>
#include<cassert>
#include<complex>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>
#include<string>
#include<vector>
#include<iostream>
#include<cstring>
#include<stack>
#include<iostream>
#include<iomanip>

#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define fup FOR
#define fdo FORD
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define siz SZ
#define CLR(x) memset((x), 0, sizeof(x))
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define FI X
#define SE Y
#define SQR(a) ((a)*(a))
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FORE(it, (x)) cerr <<*it <<", "; cout <<endl; }}
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int>P;
typedef vector<int>VI;
const int INF=1E9+7;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }

int main() {

    int n;
    int arr[100100];
    set <int> nom;
    set <int> ans;

    cin >> n;

    for(int i=0;i<n;++i)
        cin >> arr[i];

    nom.insert(arr[0]);

    for(int i=1;i<n;++i) {
        // nom.insert(arr[i]);
        set <int> tem;
        // cout << "Current : " << arr[i] << endl;
        // cout << "SEt Size : " << nom.size() << endl;

        for (set<int>::iterator it=nom.begin(); it!=nom.end(); ++it) {
             tem.insert(*it | arr[i]);
             // cout << (*it | arr[i]) << endl;
        }
        tem.insert(arr[i]);
        for (set<int>::iterator it=nom.begin(); it!=nom.end(); ++it)
             ans.insert(*it);
        nom = tem;
    }
    for (set<int>::iterator it=nom.begin(); it!=nom.end(); ++it)
         ans.insert(*it);

    cout << ans.size() << endl;
}


#include<algorithm>
#include<cassert>
#include<complex>
#include<map>
#include<iomanip>
#include<sstream>
#include<queue>
#include<set>
#include<string>
#include<vector>
#include<iostream>
#include<cstring>
#include<stack>
#include<iostream>
#include<iomanip>

#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define fup FOR
#define fdo FORD
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define siz SZ
#define CLR(x) memset((x), 0, sizeof(x))
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define FI X
#define SE Y
#define SQR(a) ((a)*(a))
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FORE(it, (x)) cerr <<*it <<", "; cout <<endl; }}
using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int>P;
typedef vector<int>VI;
const int INF=1E9+7;
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }

int main() {

    int n;
    int arr[100100];
    set <int> nom;

    cin >> n;

    for(int i=0;i<n;++i)
        cin >> arr[i];

    nom.insert(arr[0]);

    for(int i=1;i<n;++i) {
        nom.insert(arr[i]);
        for (set<int>::iterator it=nom.begin(); it!=nom.end(); ++it) {
             nom.insert(*it | arr[i]);
             cout << (*it | arr[i]) << endl;
         }
         nom.erase(arr[i-1]);
    }

    for(int i=0;i<n;i++)
        nom.insert(arr[i]);

    cout << nom.size() << endl;
}


#include <stdio.h>
#include <stdlib.h>

int n, i, j, x, Now, Ans, a[100005], hash[1000005];
int list[105], tag[105], next[21][100005];

void sort(int l, int r, int a[]);

int main()
{
	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] == 0)
			Ans = 1;
	}

	for (i = 0; i < 20; i++)
		next[i][n + 1] = n + 5;
	for (i = 0; i < 20; i++)
	{
		x = (1 << i);
		for (j = n; j >= 1; j--)
			if ((a[j] & x) > 0)
				next[i][j] = j;
			else
				next[i][j] = next[i][j + 1];
	}

	for (i = 1; i <= n; i++)
	{
		for (j = 0; j < 20; j++)
			list[j] = next[j][i], tag[j] = j;
		sort(0, 19, list);
		if (list[0] == n + 5)
			continue;
		Now = (1 << tag[0]);
		for (j = 1; j < 20; j++)
		{
			if (list[j] == n + 5)
				break;
			if (list[j] != list[j - 1])
				hash[Now] = 1;
			Now += (1 << tag[j]);
		}

		hash[Now] = 1;
	}

	for (i = 1; i < 1000000; i++)
		Ans += hash[i];
	printf("%d\n", Ans);
	return 0;
}

void sort(int l, int r, int a[])
{
	int i = l, j = r, k, mid;
	mid = a[l + rand() % (r - l + 1)];
	while (i <= j)
	{
		while (i <= j && a[i] < mid)
			i++;
		while (i <= j && a[j] > mid)
			j--;
		if (i <= j)
		{
			k = a[i], a[i] = a[j], a[j] = k;
			k = tag[i], tag[i] = tag[j], tag[j] = k;
			i++, j--;
		}
	}

	if (l < j) sort(l, j, a);
	if (i < r) sort(i, r, a);
	return;
}


#include <stdio.h>
#include <stdlib.h>

int n, i, j, x, Now, Ans, a[100005], hash[1000005];
int list[105], tag[105], next[21][100005];

void sort(int l, int r, int a[]);

int main()
{
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    for (i = 0; i < 20; i++)
        next[i][n + 1] = n + 5;
    for (i = 0; i < 20; i++)
    {
        x = (1 << i);
        for (j = n; j >= 1; j--)
            if ((a[j] & x) > 0)
                next[i][j] = j;
            else
                next[i][j] = next[i][j + 1];
    }

    for (i = 1; i <= n; i++)
    {
        for (j = 0; j < 20; j++)
            list[j] = next[j][i], tag[j] = j;
        sort(0, 19, list);
        Now = (1 << tag[0]);
        for (j = 1; j < 20; j++)
        {
            if (list[j] == n + 5)
                continue;
            if (list[j] != list[j - 1])
                hash[Now] = 1;
            Now += (1 << tag[j]);
        }

        hash[Now] = 1;
    }

    for (i = 0; i < 1000000; i++)
        Ans += hash[i];
    printf("%d\n", Ans);
    return 0;
}

void sort(int l, int r, int a[])
{
    int i = l, j = r, k, mid;
    mid = a[l + rand() % (r - l + 1)];
    while (i <= j)
    {
        while (i <= j && a[i] < mid)
            i++;
        while (i <= j && a[j] > mid)
            j--;
        if (i <= j)
        {
            k = a[i], a[i] = a[j], a[j] = k;
            k = tag[i], tag[i] = tag[j], tag[j] = k;
            i++, j--;
        }
    }

    if (l < j) sort(l, j, a);
    if (i < r) sort(i, r, a);
    return;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
    int v, e;
    cout << "Enter number of vertices : ";
    cin >> v;
    cout << "Enter number of edges : ";
    cin >> e;
    cout << "Enter edges (note: 1 is source node and n is sink node) (e.g. x y w format and x is directed towards y and w is weight of edge)...\n";
    vector<int> ed[v + 1];

}


// B. Arrays Sum

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int DiffArraysRequired = st.size()/k;
        if (st.size()%k != 0){
            ++DiffArraysRequired;
        }

        int ans = DiffArraysRequired;

        if (k==1 && st.size()>1) {
            ans = -1;
        }

        cout << ans << endl;

    }

    return 0;
}


// B. Arrays Sum

#include <iostream>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int ans;
        int c = st.size();

        // Editorial - https://codeforces.com/blog/entry/83233
        // Errichto's - https://www.youtube.com/watch?v=-L7ZmRjlHmI

        if (k==1) {
            if (c > 1) ans = -1;
            else ans = 1;
        }

        if (k >= c){
            ans = 1;
        }

        else {
            --c;
            // https://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division
            ans = (c + (k-1)-1) / (k-1);
        }

        cout << ans << endl;

    }

    return 0;
}


// B. Arrays Sum

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int ans;
        int c = st.size();

        // Editorial - https://codeforces.com/blog/entry/83233
        if (k==1) {
            if (c>1) ans = -1;
            else ans = 1;
        }
        else {
            ans = c / (k-1);
        }

        cout << ans << endl;

    }

    return 0;
}


// B. Arrays Sum

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int ans;
        int c = st.size();

        // Editorial - https://codeforces.com/blog/entry/83233
        // Errichto's - https://www.youtube.com/watch?v=-L7ZmRjlHmI

        if (k==1) {
            if (c>1) ans = -1;
            else ans = 1;
        }
        else {
            --c;
            // https://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division
            ans = (c + (k-1)-1) / (k-1);
        }

        cout << ans << endl;

    }

    return 0;
}


// B. Arrays Sum

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int ans;
        int c = st.size();

        // Editorial - https://codeforces.com/blog/entry/83233
        if (k==1) {
            if (c>1) ans = -1;
            else ans = 1;
        }
        else {
            // c - num of non-zero elements
            if (st.find(0) != st.end()){
                --c;
            }
            ans = c/(k-1);
        }

        cout << ans << endl;

    }

    return 0;
}


// B. Arrays Sum

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int ans = 1ull;
        int DiffArraysRequired = st.size()/k;
        if (st.size()%k != 0){
            ++DiffArraysRequired;
        }

        if (DiffArraysRequired > k){
            ans = -1;
        }
        else {
            ans = DiffArraysRequired;
        }

        cout << ans << endl;

    }

    return 0;
}


// B. Arrays Sum

#include <iostream>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int ans;
        int c = st.size();

        // Editorial - https://codeforces.com/blog/entry/83233
        // Errichto's - https://www.youtube.com/watch?v=-L7ZmRjlHmI

        if (k==1) {
            if (c>1) ans = -1;
            else ans = 1;
        }

        /*
        Test: #9
        1
        4 4
        1 1 1 1
        */
        else if (k >= c){
            ans = 1;
        }

        else {
            --c;
            // https://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division
            ans = (c + (k-1)-1) / (k-1);
        }

        cout << ans << endl;

    }

    return 0;
}


// B. Arrays Sum

#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main(){

    int t;
    cin >> t;

    while (t--){

        int n, k;
        cin >> n >> k;

        set<int> st;

        int tmp;
        for (int i=0; i<n; ++i){
            cin >> tmp;
            st.insert(tmp);
        }

        int ans;
        int c = st.size();

        // Editorial - https://codeforces.com/blog/entry/83233
        // Errichto's - https://www.youtube.com/watch?v=-L7ZmRjlHmI

        if (k==1) {
            if (c>1) ans = -1;
            else ans = 1;
        }

        /*
        Test: #9
        1
        4 4
        1 1 1 1
        */
        if (k >= c){
            ans = 1;
        }

        else {
            --c;
            // https://stackoverflow.com/questions/17944/how-to-round-up-the-result-of-integer-division
            ans = (c + (k-1)-1) / (k-1);
        }

        cout << ans << endl;

    }

    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[0]==a[n])
    {
        cout<<1<<endl;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=1;
    for(i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]) c++;
    }
    ll ans=ceil(c*1.0/k);
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=1;
    for(i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]) c++;
    }
    ll ans=ceil(c*1.0/(k));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k,i;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    if(a[n]!=a[n-1]) c++;
    if(c<=k)
    {
        cout<<1<<endl;
        return;
    }
    set<ll>s;
    ll j;
    s.insert(a[1]);
    ll ans=1;
    vll v;
    for(i=2;i<=n;i++)
    {
        if(s.count(a[i]))
        {
            continue;
        }
        else
            ans++;
        v.pub(a[i-1]);
        for(j=0;j<v.size();j++)
            s.insert(v[j]+a[i]);
        s.insert(a[i]);
    }
    //cout<<ans<<endl;
    ans=ceil((ans*1.0)/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[0]==a[n])
    {
        cout<<1<<endl;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]) c++;
    }
    ll ans=ceil(c*1.0/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]) c++;
    }
    ll ans=ceil(c*1.0/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    ll ans=ceil(c*1.0/(k-1));
    if(ans<0) ans=1;
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}