Crystals

No attempts yetTime limit1sMemory limit128 MB

Problem

Byteman is a scientist who studies how crystals form from the atoms of different elements. He has designed a special process for growing crystals and derived a formula that describes which combinations of atoms make a valid crystal. He now wants to know how many different crystals his process can produce.

For non-negative integers xx and yy, let xyx \oplus y denote their bitwise exclusive or (XOR). On single bits it is defined by 11=00=01 \oplus 1 = 0 \oplus 0 = 0 and 01=10=10 \oplus 1 = 1 \oplus 0 = 1.

There are nn elements, numbered from 11 to nn. For each element ii there is an upper bound mim_i on the number of atoms of that element that a single crystal may contain. A crystal that uses aia_i atoms of element ii (for i=1,,ni = 1, \dots, n) can be formed if and only if:

  • 0aimi0 \le a_i \le m_i for every i=1,,ni = 1, \dots, n,
  • a1a2an=0a_1 \oplus a_2 \oplus \dots \oplus a_n = 0, and
  • a1+a2++an1a_1 + a_2 + \dots + a_n \ge 1.

The last condition simply states that every crystal must contain at least one atom. Two crystals are considered different if they differ in the number of atoms of at least one element.

Write a program that reads the number of elements and the per-element upper bounds, computes the number of different crystals that can be formed, and prints that number.

Input

The first line contains the number of elements nn (1n501 \le n \le 50). The second line contains nn positive integers m1,,mnm_1, \dots, m_n separated by single spaces, where 1mi<23211 \le m_i < 2^{32} - 1.

Output

Print a single integer: the total number of different crystals that can be formed. This number is guaranteed to be smaller than 2642^{64}.

Example

For the input with n=3n = 3 and upper bounds 2 1 32\ 1\ 3, the answer is 55. Written as (a1,a2,a3)(a_1, a_2, a_3), the five crystals are (0,1,1)(0, 1, 1), (1,0,1)(1, 0, 1), (1,1,0)(1, 1, 0), (2,0,2)(2, 0, 2), and (2,1,3)(2, 1, 3).