Bytecomputer

No attempts yetTime limit3sMemory limit512 MB

Problem

You are given a sequence of nn integers x1,x2,,xnx_1, x_2, \dots, x_n, each of them from the set {1,0,1}\{-1, 0, 1\}. The bytecomputer is a device that allows one operation on the sequence: choose an index ii with 1i<n1 \le i < n and increase xi+1x_{i+1} by xix_i. The range of integers the bytecomputer can store is unlimited, so in principle each xix_i can become arbitrarily small or arbitrarily large.

You want the sequence to be non-decreasing, that is, x1x2xnx_1 \le x_2 \le \dots \le x_n. Find the minimum number of operations needed.

Input

The first line contains one integer nn, the length of the sequence (1n10000001 \le n \le 1\,000\,000).

The second line contains the nn elements of the sequence x1,x2,,xnx_1, x_2, \dots, x_n in order, separated by single spaces (xi{1,0,1}x_i \in \{-1, 0, 1\}).

Output

Print on one line the minimum number of operations that make the sequence non-decreasing. If no sequence of operations achieves that, print BRAK instead. BRAK is Polish for none.

Hint

Three operations turn the sequence 1,1,0,1,0,1-1, 1, 0, -1, 0, 1 into 1,1,1,1,0,1-1, -1, -1, -1, 0, 1.