Under construction

Still being built. Things may change

Fibonacci representations

Time limit2sMemory limit512 MB

Summary
Given a sequence a, report after each prefix the number of ways to write the sum of F_{a_i} as distinct Fibonacci numbers, modulo 1e9+7.
Level

Hard9 of 10

Topics
Segment tree, Dynamic programming, Matrix
Solved
No attempts yet

Statement

The Fibonacci sequence is defined as:

  • F1=1F_1 = 1
  • F2=2F_2 = 2
  • Fn=Fn−1+Fn−2F_n = F_{n-1} + F_{n-2} for n≥3n \ge 3

The first few terms are 1,2,3,5,8,13,21,…1, 2, 3, 5, 8, 13, 21, \ldots

For a positive integer pp, let X(p)X(p) be the number of different ways to write pp as a sum of distinct Fibonacci numbers. Two ways differ if some Fibonacci number appears in exactly one of them.

You are given a sequence of nn positive integers a1,a2,…,ana_1, a_2, \ldots, a_n. For each non-empty prefix a1,a2,…,aka_1, a_2, \ldots, a_k, define pk=Fa1+Fa2+⋯+Fakp_k = F_{a_1} + F_{a_2} + \cdots + F_{a_k}. Find X(pk)X(p_k) modulo 109+710^9 + 7 for every k=1,…,nk = 1, \ldots, n.

Input

The first line contains an integer nn (1≤n≤100 0001 \le n \le 100\,000). The second line contains nn space-separated integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1091 \le a_i \le 10^9).

Output

Print nn lines. The kk-th line contains X(pk)X(p_k) modulo 109+710^9 + 7.

Examples1

  1. Example 1

    Input
    4
    4 1 1 5
    
    Expected output
    2
    2
    1
    2