import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lewin
 */
public class and_circle_lewin {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader2 in = new InputReader2(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        AndCircle solver = new AndCircle();
        solver.solve(1, in, out);
        out.close();
    }

    static class AndCircle {
        int mod = 998244353;
        int MAXB = 61;

        public void solve(int testNumber, InputReader2 in, OutputWriter out) {
            int n = in.nextInt();
            long[] arr = in.readLongArray(n);
            long alland = (1L << MAXB) - 1;
            for (long x : arr) alland &= x;
            if (alland > 0) {
                // all numbers share a common bit
                // We can add any of the 2^n separators, except exactly one separator (since that's equivalent to zero)
                out.println((Utils.mod_exp(2, n, mod) - n + mod) % mod);
                return;
            }

            // fix the value of partition that contains element zero
            // there are only MAXB different options
            long[] suffand = new long[n + 1];
            HashSet<Long> vs = new HashSet<>();
            suffand[n] = arr[0];
            vs.add(suffand[n]);
            for (int i = n - 1; i >= 0; i--) {
                suffand[i] = suffand[i + 1] & arr[i];
                vs.add(suffand[i]);
            }
            vs.remove(0L);

            long ans = 0;
            for (long first_and : vs) {
                // replace first element with first_and, then do linear dp
                arr[0] = first_and;
                long[] dp = new long[n + 2];
                dp[0] = 1;
                long[] psum = new long[n + 2];
                psum[0] = 1;

                int[] bitcount = new int[MAXB];

                int front = 0;
                for (int i = 1; i <= n; i++) {
                    for (int j = 0; j < MAXB; j++) bitcount[j] += ((arr[i - 1] >> j) & 1);

                    outer:
                    while (true) {
                        for (int j = 0; j < MAXB; j++) if (bitcount[j] == i - front) break outer;
                        for (int j = 0; j < MAXB; j++) bitcount[j] -= ((arr[front] >> j) & 1);
                        front++;
                    }

                    dp[i] = (psum[i - 1] - (front == 0 ? 0 : psum[front - 1]) + mod) % mod;
                    psum[i] = (psum[i - 1] + dp[i]) % mod;
                    if (suffand[i] == first_and) {
                        ans = (ans + dp[i]) % mod;
                    }
                }

            }
            out.println(ans);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }

    static class InputReader2 {
        private BufferedReader in;
        private StringTokenizer st;

        public InputReader2(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public long[] readLongArray(int tokens) {
            long[] ret = new long[tokens];
            for (int i = 0; i < tokens; i++) {
                ret[i] = nextLong();
            }
            return ret;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

    }

    static class Utils {
        public static long mod_exp(long b, long e, long mod) {
            long res = 1;
            while (e > 0) {
                if ((e & 1) == 1)
                    res = (res * b) % mod;
                b = (b * b) % mod;
                e >>= 1;
            }
            return res % mod;
        }

    }
}

