2048

This problem is somehow inspired by the well known 2048 game. Here, you
are given a collection of natural numbers between 1 and 2048. The only
allowed operation is to pick any two equal numbers, remove them from the
collection, and add their sum to the collection. You win if you manage
to get exactly the number 2048 after zero or more operations.

Given a sequence of n numbers, consider all the subsequences of
consecutive numbers in it. How many of them have a collection of numbers
for which you can win?

Input

Input consists of several cases, each one with n followed by n natural
numbers between 1 and 2048. Assume 1 ≤ n ≤ 10⁴.

Output

For every case, print the number of winnable subsequences.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:52:20.759Z

© Jutge.org, 2006–2026.
https://jutge.org
