[Question]
  [
In musical notation, groups of notes shorter than one beat are joined together by a line at the bottom called a beam. Here are a few bars of music with the beams highlighted:
[![enter image description here](https://i.stack.imgur.com/zci9B.png)](https://i.stack.imgur.com/zci9B.png)
(Taken from *Second Suite in F* by Gustav Holst; you can hear how these notes sound at [0:13 in this video](https://www.youtube.com/watch?v=7nz7tvRdL94).)
You may notice that beam #6 is above the ovals that define the notes, and its vertical lines attached to their right sides, while the others are below the notes and attached to their left. What determines this? There are a few simple rules, which are the subject of this challenge.
1. By default, the placement of the beam is determined by its highest or lowest note. If the note farthest from the centermost line of the staff is above it, then the beam goes below the notes. If the note with the highest absolute value is above the centermost line of the staff, then the beam goes below the notes.
2. If the highest and the lowest note are the same distance from the center line, the direction of the beam is determined by which side of the center line the majority of notes in the beam lie on. If a majority of notes lie above the centre line, the beam goes down. If a majority of notes lie below the centre line, the beam goes up. Notes on the center line do not count either way.
3. If the highest and the lowest note are the same distance from the center line, and equally many notes lie above and below the center line, the beam may be placed either above or below the notes.
In the sample notation above, the beams of clusters #1, 2, 3, and 5 are determined to be below the notes because their highest notes (their second, second, first, and third respectively) are above the center line. #6's lowest note is its first/third note, which is below the center line. #4's highest and lowest note are equally distant from the center line and it contains no majority either way. Its beam could be placed either above or below, but my composition program renders it as below.
# Your commission
Write a program that takes in a list of integers, which may be zero or negative, and outputs a truthy/falsey value. These integers represent notes and their distance from the center line; positive values represent notes above the line, zero represents notes on the line, and negative values represent notes below the line. Determine, given a cluster of notes that sit those distances from the center line, which way the cluster's beam should go; output `TRUE` if the beam should go above the notes and `FALSE` if the beam should go below the notes. To restate the rules above and give the algorithm:
1. Find the number in the list with the largest absolute value. If it is greater than zero, output `FALSE`. If it is less than 0, output `TRUE`. If it is 0, output may be `TRUE` or `FALSE` as convenient. If there are positive and negative numbers with the same, maximal absolute value, continue.
2. Determine whether the majority of numbers are positive and negative, ignoring zeroes. If a majority of numbers are positive, output `FALSE`. If a majority of numbers are negative, output `TRUE`.
3. Otherwise, output may be `TRUE` or `FALSE` as convenient.
You might be given only one number. In that case, it has the highest absolute value, so if it is greater than 0 output false; if it is less than zero output true; and if it is 0 you may output true or false.
You may not assume the numbers are sorted.
# Test cases
```
5, 4, 3 -> FALSE                     # #3
1, 0, -1 -> TRUE or FALSE            # #4
0, 1, 2, 0 -> FALSE                  # #5
-2, -1, -2 -> TRUE                   # #6
3, 1, 4, 1, 5, -9 -> TRUE            # Largest absolute value below 0, rule 1
3, 1, 4, 1, 5, -5 -> FALSE           # Largest absolute value tied, determined by majority, rule 2
3, 1, -3, -1, 5, -5 -> TRUE or FALSE # Largest absolute value tied and no majority, unspecified
```
  
[Answer]
# [R](https://www.r-project.org/), 40 bytes
```
function(x)min(x)+max(x)+mean(sign(x))<0
```
[Try it online!](https://tio.run/##K/qfpmCr8D@tNC@5JDM/T6NCMzcTRGrnJlaAqdTEPI3izHSQmKaNwf80jWQNUx0FEx0FY01NLhDPUEfBQEdB1xDKBbKBIkZAQaiArhFIFoiNFKAixmAlJmASaJauJS4JUxRxXWOIQWAZoJb/AA "R – Try It Online")
If `min(x)+max(x)` is non-zero, its sign corresponds to the note farthest from the centre and gives the direction of the beam. 
Adding `mean(sign(x))` can never change the sign. Indeed, either (a) all notes are of the same sign and `mean(sign(x))` is of the same sign as `min(x)+max(x)` or (b) notes are of both signs and `mean(sign(x))` is strictly in \$(-1,1)\$ whereas `min(x)+max(x)` is an integer, so the sign of the sum is unchanged.
If `min(x)+max(x)==0`, the sign of the mean decides the direction. 
If undecided, defaults to `FALSE`.
[Answer]
# [Python 3](https://docs.python.org/3/), 55 bytes
```
lambda a:(min(a)+max(a)or sum((i>0)-(i<0)for i in a))<0
```
[Try it online!](https://tio.run/##K6gsycjPM/6fZhvzPycxNyklUSHRSiM3M08jUVM7N7ECSOUXKRSX5mpoZNoZaOpqZNoYaKYBhTIVMvMUEjU1bQz@FxRl5pVopGlEm@oomOgoGCsggVhNTQVlBTdHn2BXLrg6Qx0FAx0FXUMMdSFBoa4KQMPR1AMVA7UYAXXhN1fXCGQqEBthMRehzBhsnAmYBDpZ15I4ZaY4bIWo0zWG2A1WicU3/wE "Python 3 – Try It Online")
[Answer]
# JavaScript (ES6), ~~66~~ 64 bytes
```
a=>(a.map(m=v=>(k+=v>0||-!!v,a=v>a?a:v,m=v<m?m:v),k=0)|a+m||k)<0
```
[Try it online!](https://tio.run/##lY89D4IwEIZ3f8W50dgCgg4SKnHQycmPyThcEIxiKUHTqf8dT1yMEqNN2lzS57n37owGr2l9qm6i1IesyWWDcuqgq7BylDRUFwNppr61ot83HKnGBCPD6TNWiYoM44X0mcWBsrZgsd@kurzqS@Ze9NHJnd2Yw4hDCC9nzxh4Hixmy/W894YPOfgcxPAT36y2c9B1t0YOmQHJP6WI4JFBN@hKeafDtvmofWkdMfmLHn8f5YmL8DlQK3Qt3NwB "JavaScript (Node.js) – Try It Online")
### Commented
```
a => (                   // a[] = input array, re-used to store the minimum value
  a.map(m =              // initialize m = maximum to a non-numeric value
    v => (               // for each value v in a[]:
      k +=               //   update k:
        v > 0 ||         //     increment it if v > 0
        -!!v,            //     decrement it if v < 0
      a = v > a ? a : v, //   update a to min(a, v) (always v if a is non-numeric)
      m = v < m ? m : v  //   update m to max(m, v) (always v if m is non-numeric)
    ),                   //
    k = 0                //   start with k = 0
  )                      // end of map()
  | a + m                // use a + m if it's not equal to 0
  || k                   // otherwise, use k
) < 0                    // test if the above value is negative
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~13~~ 9 bytes
```
ṠÆm+Ṁ+Ṃ<0
```
[Try it online!](https://tio.run/##y0rNyan8///hzgWH23K1H@5sAOImGwOgwD7rRw1zFHTtFB41zLU@3M71cPeWo5PCDrc/aloT@f@/kpKSqY6CiY6CMZehjoKBjoKuIReQBLKNgFwuXSOQCBAbcRmDRU3AJFCLriWGiClURNcYogksBrQAAA "Jelly – Try It Online")
A monadic link taking a list of integers and returning a Jelly Boolean indicating the direction of the stems as per the spec. 
Modified with inspiration from [@RobinRyder’s excellent R answer](https://codegolf.stackexchange.com/a/198134/42248) so be sure to upvote that one too!
## Explanation
```
Ṡ         | Signs
 Æm       | Mean
   +Ṁ     | Add max (of original argument)
     +Ṃ   | Add min (of original argument)
       <0 | Less than 0
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), ~~15~~ ~~14~~ 13 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ÄZQÏ‚¤Ëè.±Od≠
```
Output will be false if either of the two is a possible output.
-1 byte and fixed a bug for `[0,0,1,-1,-1]` thanks to *@Grimmy*.
[Try it online](https://tio.run/##yy9OTMpM/f//cEtU4OH@Rw2zDi053H14hd6hjf4pjzoX/P8fbaxjqGMCxKY6uqaxAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeXhCf8Pt0QFHu5/1DDr0JLD3YdX6B3a6J/yqHPBf53/0dGmOiY6xrE60YY6Bjq6hkCGgY6hjpGOAZClawQU0dE1AjKNgYImQGyqo2uJyjWFcnWNQYqhAgZAwwzAhhrpGIOlQFaADQPxjME2gizShdgEUm8ItswwNhYA).
**Explanation:**
```
Ä         # Convert each value in the (implicit) input-list to their absolute value
          #  i.e. [3,1,-5,4,1,5,-5] → [3,1,5,4,1,5,5]
          #  i.e. [0,1,-2,0] → [0,1,2,0]
 Z        # Push the maximum of these absolute values (without popping the list itself)
          #  i.e. [3,1,5,4,1,5,5] → 5
          #  i.e. [0,1,2,0] → 2
  Q       # Check for each absolute value whether it's equal to this maximum
          #  i.e. [3,1,5,4,1,5,5] and 5 → [0,0,1,0,0,1,1]
          #  i.e. [0,1,2,0] and 2 → [0,0,1,0]
   Ï      # And only leave the values of the (implicit) input-list at the truthy indices
          #  i.e. [3,1,-5,4,1,5,-5] and [0,0,1,0,0,1,1] → [-5,5,-5]
          #  i.e. [0,1,-2,0] and [0,0,1,0] → [-2]
    ‚     # Pair it with the (implicit) input-list
          #  i.e. [3,1,-5,4,1,5,-5] and [-5,5,-5] → [[3,1,-5,4,1,5,-5],[-5,5,-5]]
          #  i.e. [0,1,-2,0] and [-2] → [[0,1,-2,0],[-2]]
     ¤    # Push the last value of this pair (without popping) again
      Ë   # And check if all values are equal (1 if truthy; 0 if falsey)
          #  i.e. [-5,5,-5] → 0
          #  i.e. [-2] → 1
       è  # Use it to index into the pair
          #  i.e. [[3,1,-5,4,1,5,-5],[-5,5,-5]] and 0 → [3,1,-5,4,1,5,-5]
          #  i.e. [[0,1,-2,0],[-2]] and 1 → [-2]
.±        # Take the signum of each value
          #  i.e. [3,1,-5,4,1,5,-5] → [1,1,-1,1,1,1,-1]
          #  i.e. [-2] → [-1]
  O       # Sum those together
          #  i.e. [1,1,-1,1,1,1,-1] → 4
          #  i.e. [-1] → -1
   d      # Check if it's non-negative (>=0)
    ≠     # And invert the boolean (so basically check if it's negative / <0)
          #  i.e. 4 → 1 → 0
          #  i.e. -1 → 0 → 1
          # (after which this is output implicitly as result)
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 58 bytes
```
O#`\S+
\d+
$*
+` -1+ +1+ 
 
^-(1+)($| ((?!.*\1$)|-.* \1$))
```
[Try it online!](https://tio.run/##TYstDwIxEET9/oohlGTbzV76cRWnkEgEtiElAYFBXJD330t7CvGSeZOZ9fV9fx7txJfarsdabkLlKWQcSYUGgXQIdFcOYtlsYD4fJleCsZtODiPY1jJmJArw/UQeARGeNHaDRkq9mDsZuvxL3kXTmA39AQ "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
O#`\S+
```
Sort the numbers numerically.
```
\d+
$*
```
Convert to unary.
```
+` -1+ +1+ 
 
```
Match inner pairs of negative and positive numbers and delete them until only one negative and/or positive number remains.
```
^-(1+)($| ((?!.*\1$)|-.* \1$)
```
Output a truthy value if the (largest) negative number is the only number, or if its absolute value is greater than the largest positive number, or if another negative number remains and its absolute value equals the largest positive number.
[Answer]
# [PHP](https://php.net/), ~~178~~ ~~127~~ ~~111~~ ~~107~~ 105 bytes
```
<?php foreach($argv as$n){$c+=$s=$n<=>0;($a=$n*$s)>$m&&$x=$s;$a-$m||$x=0;$a>=$m&&$m=$a;}echo$x?$x<0:$c<0;
```
[Try it online!](https://tio.run/##HcnBCoMwEIThV/EwSG0RUqqHNtn4LEuwzSUaDEhA@@zbpYeBf/hyzCJuyjE373WbOcQLePvsDRcs3YFwIxTC4sgbq6R5Rek8Utuiqllwj3Seeoy2p78kAtvvHOKKOqE680JwxorIQ@4y6Ebpnz8 "PHP – Try It Online")
## Ungolfed
```
<?php
$notes = explode(',', $argv[1]);
$max_note = 0;
$max_sign = 0;
$counts = 0;
foreach ($notes as $note) {
    $sign = $note <=> 0;
    $counts += $sign;
    if (abs($note) > $max_note) {
        $max_sign = $sign;
    } elseif (abs($note) == $max_note) {
        $max_sign = 0;
    }
    if (abs($note) >= $max_note) {
        $max_note = abs($note);
    }
}
echo ($max_sign == 0) ? ($counts < 0) : ($max_sign == -1);
?>
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 26 bytes
```
Min@#+Max@#+Mean@Sign@#<0&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n6Zg@983M89BWds3sQJEpibmOQRnpgNFbAzU/gcUZeaVRKcp6DsoVFeb6iiY6CgY1@ooVBvqKBjoKOgagthABpBrBBQB8XSNQOJAbATiGYPluBSAwATMBJqha4mQQQiaIgR1jSFGQIRrY/8DAA "Wolfram Language (Mathematica) – Try It Online") Pure function. Takes a list of numbers as input, and returns `True` or `False` as output. Uses the same logic as [Robin Ryder's answer](https://codegolf.stackexchange.com/a/198134). Additionally, here's the 49-byte function I came up with myself:
```
Tr[{}⋃Sign@MaximalBy[#,Abs]/.{-1,1}->Sign@#]<0&
```
[Answer]
# [J](http://jsoftware.com/), 17 bytes
```
0>>./+<./+#%~1#.*
```
[Try it online!](https://tio.run/##fZCxasMwEIb3PsVPQzBNFNWy4yEmydBCp9ChLyDk@Jw4yBHIcoqXvrorux3UDhGcDn5O33foMjzyqMIuRwSGGLmvFcfrx@FtiPd7/rzc@prNv8SML4anBzqejR/ZoUKGNdIwEL5LgeC8v3A42xGMRaV0S1Bam08qw2cxg2BIvP0nFVMqk5ElkzBLp8n1dGcMcjMJDsqeqHVQRWt05wg3pb2yIG8a4bbTBBEa/3OyexxXU8lQkiPb1FcqUfRo1MXY2vW/8OQP3C8r03H5bCTf@4XhGw "J – Try It Online")
Based on [Robin Ryder's insightful alrogithm - make sure to upvote his](https://codegolf.stackexchange.com/a/198134).
* `0>` Is 0 greater than...
* `>./` The max...
* `+` Plus...
* `<./` The min...
* `+` Plus...
* `#` The input length...
* `%~` Divided into...
* `1#.` The sum of...
* `*` The signs.
[Answer]
# [Burlesque](https://github.com/FMNSSun/Burlesque), 23 bytes
```
psJ)snav/^>]j<]CL++@0.<
```
[Try it online!](https://tio.run/##SyotykktLixN/f@/oNhLszgvsUw/zi42yybW2Udb28FAz@b/f10jBV1DBV0jAA "Burlesque – Try It Online")
Following the logic of [@RobinRyder](https://codegolf.stackexchange.com/a/198134/42248). Takes input as `A B C ...`
```
psJ  # Parse input to list of ints and dup
)sn  # Map sign
av   # Average (returns double)
/^   # Swap and Dup
>]   # Max
j<]  # Min
CL++ # Collect all and sum
@0.< # <0.0
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~118~~ ~~115~~ 109 bytes
```
#define A a[p]
p;s;q;r;f(a,t)int*a;{p=t;for(q=r=*a;p--;s+=(A>0)-(A<0))q=q>A?q:A,r=r<A?r:A;a=q+r+(s>0)<(s<0);}
```
Uses Robin Ryder's method.
[Try it online!](https://tio.run/##ddDdboMgFAfwe5@CdFkCE1K/umVF2vAcWy@o4kdinYC7Mr76HNqaLSu7gIST8@N/ICNllk3TQy6LupWAA/HWnbyOGqqopgUUuEd12z8JOnSsp8WHhoppZs8dIdT4DPJDgAjkaYCQYurAj2rPsWY65Ue951Qw5WsfGtuVQmO76DhdRN1CNIDtFoTRi2fvt7EnNuwwSDCIR@p12hYLuHnM39sNnseIEaIWFKIx0lvIeSYhBgEGJHSY82pk3VdSX1E2Iyusiyx1sAwnd1H5rEg0B9kVOVS@hvX684bkjOIlKll2@zzy6rASP/@1pcvuHLZc7a9pqx9M4uvM//Fq5bc/GqevrGhEaSbSXL4B "C (gcc) – Try It Online")
[Answer]
# [~~Perl 6~~ Raku](https://github.com/nxadm/rakudo-pkg), 31 bytes
```
{0>.min+.max+sum($_».sign)/$_}
```
[Try it online!](https://tio.run/##K0gtyjH7n1uplmb7v9rATi83M09bLzexQru4NFdDJf7Qbr3izPQ8TX2V@Nr/1lxcxYmVCmkK0aY6CiY6Csax1jABQx0FAx0FXUOECJALFDQCiiPEdI1AaoDYSAEhaAxWaAImgebqWuKRM0WX0jWGmAiV/A8A "Perl 6 – Try It Online")
Based on [Robin Ryder's solution](https://codegolf.stackexchange.com/a/198134).
[Answer]
# [Factor](https://factorcode.org/), 44 bytes
```
[ dup minmax + swap [ sgn ] map mean + 0 < ]
```
[Try it online!](https://tio.run/##fZBPTwIxEMXvfIpnOMqShWU1/omJBzQmxIPIiXAouwNWS1vbrrgaPvsyEBRUpEkn6cxv3pvORGTBuGrQv7u/PccLOU0KMxGemj6IIH2QmV@/4em1IJ2Rh3UUQmmd1AFT0uSEkh8MG@1xUat9IkUHCRb4PkeIrnBz3et3t7l6wmQLMaLWDromHx8GXRj31VHvMBkz2@a4OKiZMhm1V5IcF380d8gTJhPW7PBNEZ2t6X1kT7gp@QAx9kYVgfAmVEEYkzJzxA24QhFaP9XSrdqvCf9RC5LyBnIK5GZSU45xyVt/Nk6GcmPR3lhEyep7G5N96zpgAaFzaLMjXWhvKZMTLtaqIfLCggeYiXccw8@FxRB@qjHiFq6Q0JyPcYlRdQotrFUlmh6ZIuGqJQ "Factor – Try It Online")
Port of Robin Ryder's [R answer](https://codegolf.stackexchange.com/a/198134/97916).
]