Has My Pie Been Bisected? Write a program or function that takes in a nonempty list of positive integers. You may assume it is input in a reasonable convenient format such as "1 2 3 4" or [1, 2, 3, 4].

The numbers in the input list represent the slices of a full pie chart where each slice size is proportional to its corresponding number and all slices are arranged around the chart in the order given.

For example, the pie for 1 2 3 4 is:



The question your code must answer is: Is the pie chart ever bisected? That is, is there ever a perfectly straight line from one side of the circle to the other, splitting it symmetrically in two?

You need to output a truthy value if there is at least one bisector and output a falsy value if there are none.

In the 1 2 3 4 example there is a bisection between 4 1 and 2 3 so the output would be truthy.

But for input 1 2 3 4 5 there is no bisector so the output would be falsy:



Additional Examples

Arranging numbers differently may remove bisectors.
e.g. 2 1 3 4 &rarr; falsy:



If only one number is in the input list the pie is not bisected.
e.g. 10 &rarr; falsy:



There may be multiple bisectors. As long as there are more than zero the output is truthy.
e.g. 6 6 12 12 12 11 1 12 &rarr; truthy: (there are 3 bisectors here)



Bisections may exist even if they are not visually obvious.
e.g. 1000000 1000001 &rarr; falsy:



e.g. 1000000 1000001 1 &rarr; truthy:



(Thanks to nces.ed.gov for generating the pie charts.)

Test Cases

Truthy
1 2 3 4
6 6 12 12 12 11 1 12
1000000 1000001 1
1 2 3
1 1
42 42
1 17 9 13 2 7 3
3 1 2
10 20 10

Falsy
1 2 3 4 5
2 1 3 4
10
1000000 1000001
1
1 2
3 1 1
1 2 1 2 1 2
10 20 10 1


Scoring

The shortest code in bytes wins. Tiebreaker is earlier answer.
J, 18 bytes

5 bytes thanks to Dennis.

+/e.[:,/2*+/\-/+/\


@HelkaHomba: Nope.

Usage

&gt;&gt; f =: +/e.[:,/2*+/\-/+/\
&gt;&gt; f 6 6 12 12 12 11 1 12
&lt;&lt; 4
&gt;&gt; f 10 20 10 1
&lt;&lt; 0


Ungolfed

black_magic  =: +/\-/+/\
doubled_bm   =: 2 * black_magic
flatten      =: ,/
sum          =: +/
is_member_of =: e.
f =: sum is_member_of monadic flatten doubled_bm




Previous 23-byte version:

[:+/[:+/+/=+:@-/~@(+/\)


Usage

&gt;&gt; f =: [:+/[:+/+/=+:@-/~@(+/\)
&gt;&gt; f 6 6 12 12 12 11 1 12
&lt;&lt; 4
&gt;&gt; f 10 20 10 1
&lt;&lt; 0


Ungolfed

black_magic =: -/~@(+/\)
double      =: +:
equals      =: =
sum         =: +/
monadic     =: [:
of          =: @
f =: monadic sum monadic sum (sum equals double of black_magic)




Explanation

The sum of all substrings is calculated by the black_magic. The +/\ calculate the partial sums.

For example, a b c d becomes a a+b a+b+c a+b+c+d.

The -/~ then constructs a subtraction table based on the input, so x y z becomes:

x-x x-y x-z
y-x y-y y-z
z-x z-y z-z


When applied to a a+b a+b+c a+b+c+d, the result would be:

    0  -b -b-c -b-c-d
    b   0   -c   -c-d
  b+c   c    0     -d
b+c+d c+d    d      0


This calculated the sums of all the substrings which does not contain a.

This guarantees to be enough, since if one bisection contains a, the other bisection will not contain a and also will not wrap around.