In Morse code, an letter of English alphabet is represented as a string of some length from 1 to 4. Moreover, each Morse code representation of an English letter contains only dots and dashes. In this task, we will represent a dot with a "0" and a dash with a "1".

Because there are 2^1+2^2+2^3+2^4 = 30 strings with length 1 to 4 containing only "0" and/or "1", not all of them correspond to one of the 26 English letters. In particular, each string of "0" and/or "1" of length at most 4 translates into a distinct English letter, except the following four strings that do not correspond to any English alphabet: "0011", "0101", "1110", and "1111".

You will work with a string S, which is initially empty. For m times, either a dot or a dash will be appended to S, one at a time. Your task is to find and report, after each of these modifications to string S, the number of non-empty sequences of English letters that are represented with some substring of S in Morse code.

Since the answers can be incredibly tremendous, print them modulo 10^9 + 7.

Input

The first line contains an integer m (1 ≤ m ≤ 3 000) — the number of modifications to S. 

Each of the next m lines contains either a "0" (representing a dot) or a "1" (representing a dash), specifying which character should be appended to S.

Output

Print m lines, the i-th of which being the answer after the i-th modification to S.

Examples

Input

3
1
1
1


Output

1
3
7


Input

5
1
0
1
0
1


Output

1
4
10
22
43


Input

9
1
1
0
0
0
1
1
0
1


Output

1
3
10
24
51
109
213
421
833

Note

Let us consider the first sample after all characters have been appended to S, so S is "111".

As you can see, "1", "11", and "111" all correspond to some distinct English letter. In fact, they are translated into a 'T', an 'M', and an 'O', respectively. All non-empty sequences of English letters that are represented with some substring of S in Morse code, therefore, are as follows.

  1. "T" (translates into "1") 
  2. "M" (translates into "11") 
  3. "O" (translates into "111") 
  4. "TT" (translates into "11") 
  5. "TM" (translates into "111") 
  6. "MT" (translates into "111") 
  7. "TTT" (translates into "111") 



Although unnecessary for this task, a conversion table from English alphabets into Morse code can be found [here](https://en.wikipedia.org/wiki/Morse_code).
//package com.company;
// Always comment out package when submitting.

import java.io.*;
import java.util.*;

public class Main {
    // Actual Code
    // https://codeforces.com/contest/1129/problem/C
    // strings(longest common prefix), dynamic programming
    public static class Task {
        int mod = 1_000_000_007;

        public int[] zFunction(int[] a) {
            int[] z = new int[a.length];
            for (int i = 1, l = 0, r = 0; i < z.length; ++i) {
                if (i <= r)
                    z[i] = Math.min(r - i + 1, z[i - l]);
                while (i + z[i] < z.length && a[z[i]] == a[i + z[i]])
                    ++z[i];
                if (r < i + z[i] - 1) {
                    l = i;
                    r = i + z[i] - 1;
                }
            }
            return z;
        }

        public boolean match(int[] s, int start, int end) {
            int val = 0;
            for (int i = start; i <= end; i++) {
                val += s[i] * (1 << (i - start));
            }
            return val == 12 || val == 10 || val == 7 || val == 15;
        }

        public long count(int[] number, int from, int to) {
            int n = to - from;
            if (n == 0) return 0;
            long[] count = new long[n + 1];
            for (int i = from; i < to; i++) {
                for (int j = Math.max(from, i - 3); j <= i; j++) {
                    if (j > i - 3 || !match(number, j, i)) {
                        count[i + 1 - from] = (count[i + 1 - from] + count[j - from] + 1) % mod;
                    }
                }
            }
            return count[n];
        }

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int[] number = new int[n];
            for (int i = 0; i < n; i++) {
                number[i] = sc.nextInt();
            }
            long pre = 0;
            for (int i = 0; i < n; i++) {
                int[] reverse = new int[i + 1];
                for (int j = 0; j <= i; j++) {
                    reverse[j] = number[i - j];
                }
                int[] z = zFunction(reverse);
                int match = 0;
                for (int j = 1; j < z.length; j++) {
                    match = Math.max(match, z[j]);
                }
                long tot = count(number, 0, i + 1);
                long repeat = count(number, i + 1 - match, i + 1);
                long cur = (pre + tot - repeat + mod) % mod;
                pw.println(cur);
                pre = cur;
            }
        }
    }

    // template, actual code is in class Task.
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("File.out"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.err.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000);
        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    // Faster IO with BufferedReader wrapped with Scanner
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException {return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}