[Question]
  [
## Definition and Rules
A *golfy array* is an array of integers, where each element is *higher than or equal to* the arithmetic mean of all the previous elements. Your task is to determine whether an array of positive integers given as input is golfy or not.
* You do not need to handle the empty list.
* [Default loopholes apply](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default).
* [Standard Input and Output methods apply](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods).
* You can choose any two distinct non-empty values. They **must** be consistent, and must comply with all other [decision-problem](/questions/tagged/decision-problem "show questions tagged 'decision-problem'") rules. This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), shortest code in each language wins!
## Test Cases & Example
For example the following array:
```
[1, 4, 3, 8, 6]
```
Is a golfy array, because each term is higher than the arithmetic mean of those preceding it. Let's work it out step-by-step:
```
Number -> Preceding elements -> Average -> Follows the rule?
1      -> []                 -> 0.0     -> 1 ≥ 0.0   (True)
4      -> [1]                -> 1.0     -> 4 ≥ 1.0   (True)
3      -> [1, 4]             -> 2.5     -> 3 ≥ 2.5   (True)
8      -> [1, 4, 3]          -> 2.(6)   -> 8 ≥ 2.(6) (True)
6      -> [1, 4, 3, 8]       -> 4.0     -> 6 ≥ 4.0   (True)
```
All the elements respect the condition, thus this is a golfy array. Note that for the purpose of this challenge, we will assume that the average of an empty list (`[]`) is `0`.
More test cases:
```
Input -> Output
[3]                 -> True
[2, 12]             -> True
[1, 4, 3, 8, 6]     -> True
[1, 2, 3, 4, 5]     -> True
[6, 6, 6, 6, 6]     -> True
[3, 2]              -> False
[4, 5, 6, 4]        -> False
[4, 2, 1, 5, 7]     -> False
[45, 45, 46, 43]    -> False
[32, 9, 15, 19, 10] -> False
```
---
**Note that this is *[Puzzle 1](https://github.com/Mr-Xcoder/CodeGolf-Hackathon/blob/master/Puzzle%201/Puzzle%201.md)* from *[CodeGolf-Hackathon](https://github.com/Mr-Xcoder/CodeGolf-Hackathon)* and is also posted on [Anarchy Golf](http://golf.shinh.org/p.rb?Golfy+ARrays) (that one is broken) - *[Reposted](http://golf.shinh.org/p.rb?Golfy+Arrays+with+test+cases)* by [histocrat](https://codegolf.stackexchange.com/users/6828/histocrat), but I am the original author on both sites, and thus allowed to repost them here.**
  
[Answer]
# [Python 2](https://docs.python.org/2/), 37 bytes
```
def g(a):sum(a)>len(a)*a.pop()or g(a)
```
[Try it online!](https://tio.run/##hdHPa8IwFAfwe/@Kh6dGgtjWuVnobhsMxk7eJIduPl2hS8JLCvrXdy8pqBM7Q8I7vE@/@VF79N9G532/xR3s01qUrvvh8tyi5jKtZ9bYVBiKzah26bsoEwBPxxIIfUcaPo1p0z03BDfw8IXWw5ve4uGFyNCJranDJKmdQ/KcsykUXA0BVTWws8olZLm6pzIJCwmFhCcJS/WPyqNi@zCqlhxxmqOKU/4ea1CvdesuWdgpJi3UHRYuGvGjGmfcjisExve7yQrOWnEcyyzUubpglhrtYfJhYPigMRow/Cg3m/S/ "Python 2 – Try It Online")
Outputs via exit code: crashes (exit code 1) for golfy arrays, just exits with exit code 0 for non-golfy arrays. ovs and Jonathan Frech saved 3 bytes.
### [Python 2](https://docs.python.org/2/), 44 bytes
```
f=lambda a:a and sum(a)<=len(a)*a.pop()*f(a)
```
[Try it online!](https://tio.run/##hdBND4IgGAfwe5/imSd1zCWavSyuHTt1axxo6nJTcKCHPr094FbWMhnsGePHn5f20d2VpMNQslo0t1yAOOCQOZi@8UVwZHUhsYYialXrB2GJk0EYU@gOSv@acPhqATAGF90Xq7eiBGLKl1RMICWQENgRyPgfRZ1Cu5lVGUa8@qzClM9rjeokajNl9iSXlPIFZh/q8JbPM1x2wwa6//vJEszaYxzK2NY1n7BWV7ID76xg3FApCYXWSpvIG54 "Python 2 – Try It Online")
A more traditional variant, which returns `True` for golfy arrays, else `False`. Jonathan Frech saved 2 bytes.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~6~~ 5 bytes
```
<ÆmƤE
```
[Try it online!](https://tio.run/##y0rNyan8/9/mcFvusSWu/w@3P2paA0Tu//9HR0cbx@pwKShEG@koGBpBmIY6CiY6CsY6ChY6CmZwISOwEFDCFCJkBpSEo1iQGNAsoDKILEgdWMoEzgfZABY1hwoBmWAMUgV1hTFQkSVQHVDYEEQbxMbGAgA "Jelly – Try It Online")
### How it works
```
<ÆmƤE  Main link. Argument: A (integer array)
 ÆmƤ   Compute the arithmetic means (Æm) of all prefixes (Ƥ) of A.
<      Perform element-wise comparison. Note that the leftmost comparison always
       yields 0, as n is equal to the arithmetic mean of [n].
    E  Test if all elements of the resulting array are equal, which is true if and
       only if all comparisons yielded 0.
```
[Answer]
## JavaScript (ES6), ~~33~~ 32 bytes
```
a=>a.some(e=>e*++i<(s+=e),s=i=0)
```
Code also works on negative values such as`[-3, -2]`. Returns `false` for a golfy array, `true` for other arrays. Edit: Saved 1 byte thanks to @JustinMariner.
[Answer]
## [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 35 bytes
```
Max[Accumulate@#-Range@Tr[1^#]#]>0&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73zexItoxObk0tzQnsSTVQVk3KDEvPdUhpCjaME45VjnWzkDtf0BRZl6Jg5ZCmoK@g0I1l4JCtXGtjgKINtJRMDSCsg11FEx0FIx1FCx0FMwQYkZgMaCMKVTMDCgNR1AxoAqYMSCVYDkThADIGrCwOUwMyAZjkDqYY4yByiyBKoHihiDaoJar9j8A "Wolfram Language (Mathematica) – Try It Online")
Outputs `False` for golfy arrays and `True` otherwise.
[Answer]
# [MATL](https://github.com/lmendo/MATL), ~~9~~ 8 bytes
```
tYstf/<a
```
Outputs `0` for golfy arrays, `1` otherwise.
[**Try it online!**](https://tio.run/##y00syfmf8L8ksrgkTd8m8b9LyP9o41iuaCMdBUMjIG2oo2Cio2Cso2Cho2AG4RuB@UBRUyDfDCgMR0A@UAakDSQLFjOBcEDGgYXMQXwgDcYgeZBlxkBpS6AKoJghiDaIBQA "MATL – Try It Online")
### Explanation
Consider input `[1, 4, 3, 8, 6]`.
```
t    % Implicit input. Duplicate
     % STACK: [1, 4, 3, 8, 6], [1, 4, 3, 8, 6]
Ys   % Cumulative sum
     % STACK: [1, 4, 3, 8, 6], [1, 5, 8, 16, 22]
t    % Duplicate
     % STACK: [1, 4, 3, 8, 6], [1, 5, 8, 16, 22], [1, 5, 8, 16, 22]
f    % Find: indices of nonzeros. Gives [1, 2, ..., n], where n is input size
     % STACK: [1, 4, 3, 8, 6], [1, 5, 8, 16, 22], [1, 2, 3, 4, 5]
/    % Divide, element-wise
     % STACK: [1, 4, 3, 8, 6], [1, 2.5, 2.6667, 4, 4.4]
<    % Less than?, element-wise
     % STACK: [0, 0, 0, 0, 0]
a    % Any: true if and only there is some nonzero. Implicit display
     % STACK: 0
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~53~~ ~~50~~ 48 bytes
```
and.(z(<=).scanl1(+)<*>z(*)[1..].tail)
z=zipWith
```
[Try it online!](https://tio.run/##bY6xDsIgEIb3PsWlEygSaWvVpPUJdHJwqAyk1UpEJC0ufXgRiHEygfDfd/9/x02M94tSrocazk7ojqIJVTWmYyu0YmiOq9luQjPcMEo5tUIqnEz1JM1J2pt7CKl9snsm8BDmAMgMUlug0GNompwTaDICLAuCESgI5AQ2BMovyCLweBVA6Ru/w3kC5mWPdtjrNP0/3w8IuZCPoeJbhZ2RrSPwIt7giH/KvWHrPR6y8C45d@/2qkQ/ukVrzAc "Haskell – Try It Online")
*Edit:* -3 bytes thanks to Zgarb!
**Explanation**
The above point-free version is equivalent to the following program:
```
f s = and $ zipWith(<=) (scanl1(+)s) (zipWith(*)[1..](tail s))
```
Given an input `s=[1,4,3,8,6]`, `scanl1(+)s` computes the prefix sums `[1,5,8,16,22]` and `zipWith(*)[1..](tail s)` drops the first element and multiplies all other elements with their index: `[4,6,24,24]`. The list is now *golfy* if pairwise the prefix sums are smaller or equal to the elements times index, which can be checked by zipping both lists with `(<=)` and checking that all results are `True` with `and`.
[Answer]
# [C# (Visual C# Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 71 + 18 = 89 bytes
```
x=>x.Select((n,i)=>new{n,i}).Skip(1).All(y=>x.Take(y.i).Average()<=y.n)
```
additional 18 bytes for `using System.Linq;`
[Try it online!](https://tio.run/##jdFBa4MwGAbgc/MrvmMCWZjWdRtWYQx22mDgYAfxkGWphNq4JWlXEX@7ix5KaUGUhMSQ580XFfZGWNHvrdIlZI11chej8zf2qvRvjETFrYV3U5eG76BFC@u4UwIOtfqGN640ts54lRfATWkJtPCy12KttMsL@lXXVQobSAD1xyQ9skxWUjiMNVUkSbX8a/2sIyzbqh8cEPZUVbgZNn7wrcQNU37pIA0vJSbrpGGa9DF6rrWtK8k@jXLSlynxBvuovGiXHSExXD4TIKQQhFdoAgQUIgpLCg8UVic4DcIReHY3B6x88KnNAT77@gpTYKhkjI/O2TQYPtTI7ueUFPmNYx8OOf2UqTv4/Ed/hDfBMN6OBqFFh7r@Hw "C# (Visual C# Compiler) – Try It Online\"(n,i)=>new{n,i}).Skip(1).All(y=>x.Take(y.i).Average()<=y.n")
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 10 bytes
This is an anonymous tacit prefix function (called a monadic train in APL terms).
```
∧/⊢≥+\÷⍳∘≢
```
[Try all the test cases on TIO!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RHHcv1H3UtetS5VDvm8PZHvZsfdcx41LkIKKlgzJWmYKRgaASkDBVMFIwVLBTMwGwjINtEwRTINoNBINtYAaQSKA7km4BZQM1AnjmIbQpGQAmQocZGCpYKhqYKhkDSAAA "APL (Dyalog Unicode) – Try It Online")
*Is it*
 `∧/` all-true that
 `⊢` the elements
 `≥` are greater than or equal to
 `+\` the cumulative sums
 `÷` divided by
  `⍳` the integers 1 through
  `∘` the
  `≢` number of elements
*?*
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~62~~ ~~60~~ 62 bytes
* Removed two superfluous parentheses.
* Added two bytes to fix function's reusability (`b=`).
```
f(A,S,k,b)int*A;{for(S=k=b=0;*A;S+=*A++)b+=!(S<=*A*k++);b=!b;}
```
[Try it online!](https://tio.run/##fZDNasMwEITPzVNsAgXJ3oLttm6DooPzn1x9bHKoXByCiVtCb8bP7q4lV@iQCGTEzjeDtVM8nYqi60qWYY4VKn6uf4NMNOX3leWykkpGguY8lEEWhlyFcszyGQ1BRaNQcqxE210@zzXjzeiB0pB9HEFC84wQtcJIcyMlCHHiyAsjxwgvCOR/R0gdvLQ40ZhMrw5eGZzqkD0a/1zJULLJ4xdICfGhniDQipzfZXMPW3jY0sNWmpnHrm0pbgEbo5rFUr2hZVvL@tq0483BuwGTrL8@7Va@H35I4SnlyRL3d3SzoWh48frGNv9s42FbD9t52L5no7b7Aw "C (gcc) – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 5 bytes
```
ηÅA÷W
```
[Try it online!](https://tio.run/##MzBNTDJM/f//3PbDrY6Ht4f//x9tpgOFsQA "05AB1E – Try It Online")
Extensive help from Dennis and Adnan got to this reduced version. Also a bug was fixed to make this possible, thanks again you guys. I take little credit for this answer.
---
# [05AB1E](https://github.com/Adriandmen/05AB1E), 10 bytes
```
ηεÅA}ü.S_P
```
[Try it online!](https://tio.run/##MzBNTDJM/f//3PZzWw@3OtYe3qMXHB/w/3@0mQ4UxgIA "05AB1E – Try It Online")
---
~~Long because `DgsO/` is the equivalent of "mean" in 05AB1E.~~
Apparently `ÅA` is arithmetic mean.
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), 15 bytes
```
∧/⊢≥((+/÷≢)¨,\)
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///P@1R24RHHcv1H3UtetS5VENDW//w9kedizQPrdCJ0QRKKxhzpSkYKRgaASlDBRMFYwULBTMw2wjINlEwBbLNYBDINlYAqQSKA/kmYBZQM5BnDmKbghFQAmSosZGCpYKhqYIhkDQAAA "APL (Dyalog Unicode) – Try It Online")
**How?**
```
            ,\  all prefixes
           ¨    for each
      +/÷≢      calculate arithmetic mean
  ⊢≥            element wise comparison
∧/              logically and the result
```
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), 60 bytes
```
param($a)$o=1;$a|%{$o*=$_-ge($a[0..$i++]-join'+'|iex)/$i};$o
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/vyCxKDFXQyVRUyXf1tBaJbFGtVolX8tWJV43PRUoHG2gp6eSqa0dq5uVn5mnrq1ek5laoamvkllrrZL///9/Bw1DHQUTHQVjHQULHQUzTQA "PowerShell – Try It Online")
Takes input as a literal array (e.g., `@(1, 4, 3, 8, 6)`) into `$a`. Sets our `$o`utput variable to be `1`. Then loops through `$a`. Each iteration, we're (ab)using PowerShell's implicit casting to `*=` the result of a Boolean comparison against our `$o`utput. The Boolean is whether the current value `$_` is `-g`reater-than-or-`e`qual to the previous terms `$a[0..$i++]` added together (`-join'+'|iex`) divided by how many terms we've already seen `$i`. So, if any step along the way is false, then `$o` will get multiplied by `0`. Otherwise, it will remain `1` throughout.
We then simply place `$o` onto the pipeline and output is implicit. `1` for truthy and `0` for falsey.
[Answer]
# Perl 5, 27 +2 (-ap) bytes
```
$_=!grep$_*++$n<($s+=$_),@F
```
[Try It Online](https://tio.run/##K0gtyjH9/18l3lYxvSi1QCVeS1tbJc9GQ6VY21YlXlPHwe3/fzMFCDT9l19QkpmfV/xfN7EAAA)
[Answer]
# [C# (.NET Core)](https://www.microsoft.com/net/core/platform), 74 bytes
```
x=>{for(int i=1,s=0;i<x.Count;)if(x[i]<(s+=x[i-1])/i++)return 0;return 1;}
```
[Try it online!](https://tio.run/##nZJPa4MwGMbvfor3GGnaadt1G9FeCtulg7Eddig9SBrlBZtAEjeH@NldkpXSwy4ajObf73memHAz50qLoTEoK/j4MVacWXTbW@xUXQtuUUmzeBFSaOQsinhdGANvWlW6OEddBK4YW1jk8KXwBK8FSmKsdkKHIxS6MnFY87fSl@dG8myPxmYo7ZaCf0MJ@dDm265UmrgBwDylJk8YZq0L0kjLYixJe8BjRswsd415eozvcDaLtbCNlpCwSyNl/cCubjsXX9Vi8anRij1KQUoixTdcA0AHK@jjeByypJAux2MphTWFFYVHCptJ@DLgTuR@PL6hN8943PlO2LKPGhzXk1j/o4PCwwTcYaF69xGHDJm/lBD27PyfXASnkvpv8r/KuyhOQeQy10f98As "C# (.NET Core) – Try It Online")
Returns 0 for false and 1 for true.
3 Bytes longer than core of [chryslovelaces](https://codegolf.stackexchange.com/users/75118/chryslovelace) [answer](https://codegolf.stackexchange.com/a/145706/42502). But in total several Bytes shorter because my variant doesn't need any `using` statements.
[Answer]
# [Cubix](https://github.com/ETHproductions/cubix), 35 bytes
```
/I?/\+psu0^.\)*sqs;-\;;U;O1.....?@^
```
[Try it online!](https://tio.run/##Sy5Nyqz4/1/f014/RruguNQgTi9GU6u4sNhaN8baOtTa31APBOwd4v7/N1YwAgA "Cubix – Try It Online")
Not the most efficient use of space (6 no-ops in the code) Produces no output for a golfy array, `1` for a not-golfy array.
Expands to the following cube:
```
      / I ?
      / \ +
      p s u
0 ^ . \ ) * s q s ; - \
; ; U ; O 1 . . . . . ?
@ ^ . . . . . . . . . .
      . . .
      . . .
      . . .
```
Explanation forthcoming, but it basically ports something like Luis Mendo's [MATL answer](https://codegolf.stackexchange.com/a/145715/67312) or Dennis' [Julia answer](https://codegolf.stackexchange.com/a/145818/67312).
[Watch it run!](http://ethproductions.github.io/cubix/?code=ICAgICAgLyBJID8KICAgICAgLyBcICsKICAgICAgcCBzIHUKMCBeIC4gXCApICogcyBxIHMgOyAtIFwKOyA7IFUgOyBPIDEgLiAuIC4gLiAuID8KQCBeIC4gLiAuIC4gLiAuIC4gLiAuIC4KICAgICAgLiAuIC4KICAgICAgLiAuIC4KICAgICAgLiAuIC4K&input=MyAy&speed=5)
[Answer]
# Matlab and Octave, ~~41~~ 36 bytes
*5 bytes saved thx to Luis Mendo*
```
all([a inf]>=[0 cumsum(a)./find(a)])
```
[Try it online!](http://rextester.com/AAM39974)
[Answer]
# SQL (MySQL), 68 bytes
```
select min(n>=(select ifnull(avg(n),1)from t s where s.i<t.i))from t
```
[Try it online!](http://sqlfiddle.com/#!9/91466a/1)
Returns **1** for golfy arrays, and **0** otherwise. Takes input from a [named table](https://codegolf.meta.stackexchange.com/a/5341), `t`. In order to create `t`, run:
```
CREATE TABLE t(i SERIAL,n INT)
```
and to load the values:
```
truncate table t;insert into t(n)values(3),(2);
```
[Answer]
# [Factor](https://factorcode.org/), 26 bytes
```
[ dup cum-mean v>= vall? ]
```
[Try it online!](https://tio.run/##PY3NDoIwEITvPsW8gERA8C/q0XjxYjwZD01dlVhKbQuJGp4dV2pMm8l8nZ3tRUhf2e6w3@42c9zJalIohb9FzgtfOF9IF7ih76SDo0dNWpKDseT909hCe1xJkxWqeHGp0g6LweCNFC1rgjjpTYwxP02R/yhhGiPrKf@fti@GxjfNWYPnRcyTQFl/OQyfpAlmiDPErCO03RHn2kDW5bAkodGslmiEUmucOs61MEY9ETlIRcJ2Hw "Factor – Try It Online")
## Explanation
Factor has some pretty great words for this.
```
         ! { 1 4 3 8 6 }
dup      ! { 1 4 3 8 6 } { 1 4 3 8 6 }
cum-mean ! { 1 4 3 8 6 } { 1 2+1/2 2+2/3 4 4+2/5 }
v>=      ! { t t t t t }
vall?    ! t
```
[Answer]
# [Husk](https://github.com/barbuz/Husk), 5 bytes
```
Λ<mAḣ
```
[Try it online!](https://tio.run/##yygtzv7//9xsm1zHhzsW////P9pQx0THWMdCxywWAA "Husk – Try It Online")
Modification of Mr. Xcoder's solution from the linked repository.
-1, a sweet victory using `all2`!
# [Husk](https://github.com/barbuz/Husk), ~~8~~ 7 bytes
```
ΛΓ·<Aṫ↔
```
[Try it online!](https://tio.run/##ASIA3f9odXNr///Om86Twrc8QeG5q@KGlP///1sxLDQsMyw4LDZd "Husk – Try It Online")
Took me long enough to use `Γ` here.(more than a year!)
[Answer]
# [Ruby](https://www.ruby-lang.org/), 30 bytes
```
->a{0until a.pop*a.size<a.sum}
```
[Try it online!](https://tio.run/##VY1LDsIwDET3nMKCHQoV/fCToDuWcIEqi7QNUAmSKm0WUHr2YhsEworl8ZtJ4nx@H067YZaqbu5NW11BBbWtpypoqofe4vC3fsiyWArIIgFhRCIUkAiIBawFLD8gYoB4QWCJxvcQQI@vUoBp8tnoUWYrBii4KcGfxhjYYAZhSHMuZaBVcYHSwlM9R4CV63NlWFHVrjItjCed6mGXwvhn@LaBU6YkE6ebwms42oNuL7bcO2cd5fV//r1qU46whxc "Ruby – Try It Online")
Inspired by [Lynn's answer](https://codegolf.stackexchange.com/a/145705/73819). Throws `NoMethodError` for golfy, returns `nil` otherwise.
[Answer]
# [Python 2](https://docs.python.org/2/), 52 bytes
```
lambda A:all(k*j>=sum(A[:j])for j,k in enumerate(A))
```
[Try it online!](https://tio.run/##hdG7DoIwFAbg3ac4YQLTGLmISlITFkcnN@xQY4lcS1oYfHpsS6JoRJo2Hfr1P700j/bOa69P8aUvaXW9UYgjWpZ2scwPWHaVHSdRTpyUC8hRAVkNrO4qJmjL7NhxeiolEy2kduIT@GoOYAxn0bHFW3kIXI/MKRdBgMBHsEMQkj/KM0rZzaQKVcSrTyqV8nmsQR1pKcdMVzJJAZlh@qIGb8k0U8tm6EDzfj@Zr7L2Kk5JV89rMmKNyOoWrBOHYUPG1RcJwYVcWf0T "Python 2 – Try It Online")
# [Python 2](https://docs.python.org/2/), ~~50~~ ~~48~~ ~~44~~ 42 bytes
* Saved two bytes by inlining and using `and`.
* Saved two bytes thanks to [Mr. Xcoder](https://codegolf.stackexchange.com/users/59487/mr-xcoder) by chaining assignment `S=k=0`.
* Saved two bytes by using `or` and the comparison's boolean value as `k`'s increment value.
* Saved two bytes thanks to [ovs](https://codegolf.stackexchange.com/users/64121/ovs); raising a `NameError` by using an undefined variable instead of a `ZeroDivisionError`.
```
S=k=0
for j in input():k+=S<=j*k or J;S+=j
```
[Try it online!](https://tio.run/##TY6xbsIwEIbn@Cl@eWqLVZGEUprWUwRIHeiQblGHCBmRhMaRY1R4@vRsEkA6y7r/@87n9mz3uon6VHLO@0zWcsp22qBC2VC1R/vwmNQTmX3I6qkGkc/3bCKrnnRmzTlh@NuXB4U0YcEaEt/mqFjgCNRJbZGyQJ22qrXYFL9qaYw2CZy4Kg4dmUXXKWPHVZASazYMLL9Wg9@asrHgG42LXuoGyqHumfd5/MP81jwSCKOxCQVmArHAQmB@F0Y@JPQyhnMSrjWG5NBTl0/mzvZ4dh@5dR683lLq/HFufI1jUt/IJhK6ezqQfw "Python 2 – Try It Online")
[Answer]
# [q/kdb+](http://kx.com/download/), 14 bytes
**Solution:**
```
min x>=avgs x:
```
**Examples:**
```
q)min x>=avgs x:1 4 3 8 6
1b                           / truthy
q)min x>=avgs x:4 2 1 5 7
0b                           / falsey
```
**Explanation:**
Fairly simple with the `avgs` built-in:
```
min x>=avgs x: / solution
            x: / store input in variable x
       avgs    / calculate running averages
    x>=        / array comparison, x greater than running average
min            / take minimum of list of booleans
```
[Answer]
# [Julia 0.6](http://julialang.org/), 29 bytes
```
!x=any(find(x).*x.<cumsum(x))
```
Returns *false* or *true*.
[Try it online!](https://tio.run/##PY5hC4JADIa/@yumINzFlO7OLKGi/1F@kEy4yCs04fr11@4UYWPb875se04v3ZTOxfbUmB/rtGmZ5fnG5sf71I9TTxN33XsAC9oAiwCuqkZfJIKQcysQCgSFcEAoVyQDImE3o5LENWZE@rLC24JSrLM/EOh@QdSG9K7lCUWminyEha/bOuLEL59Bm2/HkjQT1QjZGdLxZhIEixBbHj1M6/4 "Julia 0.6 – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~38~~ 34 bytes
```
function(x)any(cumsum(x)/seq(x)>x)
```
[Try it online!](https://tio.run/##bY7bCsIwDIbvfYpdJvCD9jTdhb7LKBYGW512he3pawQvxC4JCcmX06uEawk5@mV4RFq5jxv5PKU8SXJM96eE28ol9fM8bjQOaSGDQ/MjnjSU5v@igoXBBe0O0UIsXEVafLUiBvUF2SC9dqcuDwk718ThYzJk6gsaHZSDEn9iRhO4vAE "R – Try It Online")
[Answer]
# [Add++](https://github.com/cairdcoinheringaahing/AddPlusPlus), 54 bytes
```
D,g,@@#,BFB
D,k,@,¦+AbL/
D,f,@,dbLR$€g€k0b]$+ABcB]£>ª!
```
[Try it online!](https://tio.run/##bZA7CsJAEIbr3VOsMZ0DmsT3i7hIqlRiJykSY4JvUbQRG68iWIinyFG8SJxZUYkIOyzzf/PPLr8fhptNmvYhBtvOg3Qk78McbEiuhV7gFrGLsAsDd6A/zvcYa14KPL3Qk2PpJZducsuhe7aermhBEzjTRLvTFdqMo3fpo07ayPK0A2OsJYbb/YQEE4RhKvGrGSDKICwQdRBVYhlkKoQDlSyq4vDnZBHOv99w/MVOabRAzZb/EPqV4rXXoi9DTRUZrR9ooa2BTuQG3aUMl17IGQZ3jE7YqNiOFNiJc50CSp8 "Add++ – Try It Online")
### Unoriginal version, 30 bytes
```
D,f,@,¬+AbLRBcB/@0@B]ABcB]£>ª!
```
[Try it online!](https://tio.run/##S0xJKSj4/99FJ03HQefQGm3HJJ8gp2QnfQcDB6dYRyAr9tBiu0OrFIEqsvIz83QcHJStdLg4lRRsbO0UlLK4uFx0chOB4iCxaONYpTJOTk5rhZCi0lSQgJGOgqERWBAhZqijYKKjYKyjYKGjYAaSQ5EyAksBFZiiSpkBFcMRqhRQPcwOt8ScYrAYyACwWhMsMiBXgeXNIQYh5IBiYAzSaIwmaQzUZgnUCZQ3BNEGKPJOsSlcnI@a1lSn1QI54GCrBgVYLReXCiiA/gMA "Add++ – Try It Online")
Both output **1** for golfy arrays and **0** otherwise
## How they work
The first version was created by me, without checking any other solutions. The second was inspired by Dennis' [comment](https://codegolf.stackexchange.com/questions/145699/am-i-a-golfy-array/145762#comment356541_145719), so I'm less happy with it.
### The first version
Here, we define our main function \$f\$ that computes the *golfiness* of our input array, \$A\$. First, we need to yield the suffixes of \$A\$, which is done by first generating the range \$B := [1, ... \vert{A}\vert]\$, where \$\vert{A}\vert\$ denotes the length of \$A\$. This is done with the code `dbLR$`, which leaves \$[B, A]\$ as the stack. We then iterate the dyadic function \$g\$ over these two lists. Being dyadic, the function binds its left argument as \$A\$ for each iterated element. It then iterates over the range \$B\$, which each element from \$B\$ being the right argument provided to \$g\$. \$g\$ is defined as
```
D,g,@@#,BFB
```
which is a dyadic function (i.e. takes \$2\$ arguments), and pushes its arguments to the stack in reversed order (`#`) before execution. `BF` then flattens the two arguments. We'll assume that the arguments are \$A\$ and \$e \in x\$. This leaves the stack as \$[...A, e]\$, where \$...\$ represents an [array splat](https://docs.python.org/3/tutorial/controlflow.html#unpacking-argument-lists). Finally, `B` takes the first \$e\$ elements of \$A\$ and returns a list containing those elements.
*Note* : The function names \$g\$ and \$k\$ aren't chosen randomly. If the commands given to an operator (such as `€`) doesn't currently have a function (which [`g` and `k` don't](https://github.com/cairdcoinheringaahing/AddPlusPlus/blob/master/add%2B%2B.py#L1082)), then the named functions are searched for a matching function. This saves \$2\$ bytes, as normally the function would have to wrapped in `{...}` to be recognised as a user-defined function. At the time of writing, the currently unused single byte commands are `I`, `K`, `U`, `Y`, `Z`, `g`, `k`, `l`, `u` and `w`.
When \$g\$ is applied over the elements of a range \$x\$, this returns a list of prefixes for \$A\$. We then map our second helper function \$k\$ over each of these prefixes. \$k\$ is defined as 
```
D,k,@,¦+AbL/
```
which is the standard implementation of the [arithmetic mean](https://en.wikipedia.org/wiki/Arithmetic_mean). `¦+` calculates the sum of the argument, `AbL` calculates its length, then `/` divides the sum by the length. This calculates the arithmetic mean of each prefix, yielding a new array, \$C\$.
Unfortunately, \$C\$ contains the mean of \$A\$ as its final element, and does not include the mean of the empty list, \$0\$. Therefore, we would have to remove the final element, and prepend a \$0\$, but popping can be skipped, saving two bytes, for reasons explained in a second. Instead, we push \$[0]\$ underneath \$C\$ with `0b]$`, then concatenate the two arrays forming a new array, \$C^+\$.
Now, we need to check each element as being less than its corresponding element in \$A\$. We push \$A\$ once again and zip the two arrays together with `ABcB]`. This is the reason we don't need to pop the final element: `Bc` is implemented with Python's [`zip`](https://docs.python.org/3/library/functions.html#zip) function, which truncates the longer arrays to fit the length of the shortest array. Here, this removes the final element of \$C^+\$ when creating the pairs.
Finally, we [starmap](https://docs.python.org/3/library/itertools.html#itertools.starmap) \$p \in A, q \in C^+; p < q \equiv \neg(p \ge q)\$ over each pair \$p, q\$ to obtain an array of all \$0\$s if the array is golfy, and array containing at least a single \$1\$ if otherwise. We then check that all elements are falsey i.e. are equal to \$0\$ with `ª!` and return that value.
### The second version
This takes advantage of Dennis' approach to remove \$24\$ bytes, by eliminating the helper functions. Given our input array of \$A\$, we first compute the cumulative sums with `¬+`, i.e the array created from \$[A\_0, A\_0+A\_1, A\_0+A\_1+A\_2, ..., A\_0+...+A\_i]\$. We then generate Jelly's equivalent of `J` (*indicies*), by calculating the range \$B := [1 ... \vert{A}\vert]\$ where \$\vert{A}\vert\$ once again means the length of the array.
Next, we divide each element in \$A\$ by the corresponding index in \$B\$ with `BcB/` and prepend \$0\$ with `@0@B]`. This results in a new array, \$C^+\$, defined as
$$C^+ := [0, A\_0, \frac{A\_0+A\_1}{2}, \frac{A\_0+A\_1+A\_2}{3}, ..., \frac{A\_0+...+A\_i}{i+1}]$$
The final part is identical to the first version: we push and zip \$A\$ with \$C^+\$, then starmap inequality over each pair before asserting that all elements in the resulting array were falsy.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
Kvṁ<≈
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJLduG5gTziiYgiLCIiLCJbMSwgNCwgMywgOCwgNl0iXQ==)
Porting jelly got me feeling like yeet.
## Explained
```
Kvṁ<≈
K     # prefixes of the input
 vṁ   # the mean of each of those prefixes
   <  # is the input less than each of those means? 
    ≈ # and is everything the same? 
```
[Answer]
# [Desmos](https://desmos.com/calculator), 55 bytes
```
f(l)=\sum_{n=2}^{l.\length}\{l[1...n-1].\mean>l[n],0\}
```
Outputs `0` for golfy array, and a positive integer otherwise.
[Try It On Desmos!](https://www.desmos.com/calculator/qpyjlv6fxf)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/nctchn5mvi)
[Answer]
# [Scala](http://www.scala-lang.org/), 109 bytes
Golfed version, [try it online!](https://tio.run/##hZHPS8MwFIDv@yseOyWjlLWdU6sZ6E3QXcTTEHnWtIukqSTZQUr/9voShpeNNeQn@fK9l8RVqHHsPr9l5eEFlYF@/JI11AzLZ@X87sn4d14@dp2WaESP0KKv9n2FTsJWabHx9iDv4vJDbDB1h/ZeMEy1NI3fL2iCzi@YqhkpU2WU5zwDqYlfcj4MI0CI11JohrZxJTxYi7@7V2@VaSg0vNEZENDPgAo6J60nV0iOFZyDEBBS4Ge28wSy/DKSJbBKoEjgJoH1JJpHlA5cXUbXJPuvl1HyHVOskR7lHBLiRdVqGgxXjvj1FEtMbMFbTMAFaW/JTHwWxuUJH7sf@jKvDZtvu6NAdQaktZ116TyAw2wY/wA)
```
def f(a:List[Int]):Boolean={a match{case Nil=>true;case _=>a.sum<=(a.length*a.last*(if(f(a.init))1 else 0))}}
```
Ungolfed version
```
object Main {
  def f(a: List[Int]): Boolean = {
    a match {
      case Nil => true
      case _ => a.sum <= (a.length * a.last * (if(f(a.init)) 1 else 0))
    }
  }
  def main(args: Array[String]): Unit = {
    assert(f(List(3)) == true)
    assert(f(List(2, 12)) == true)
    assert(f(List(1, 4, 3, 8, 6)) == true)
    assert(f(List(1, 2, 3, 4, 5)) == true)
    assert(f(List(6, 6, 6, 6, 6)) == true)
    assert(f(List(3, 2)) == false)
    assert(f(List(4, 5, 6, 4)) == false)
    assert(f(List(4, 2, 1, 5, 7)) == false)
    assert(f(List(45, 45, 46, 43)) == false)
    assert(f(List(32, 9, 15, 19, 10)) == false)
    
    println("No assertion errors.")
  }
}
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 11 10 bytes
-1 byte thanks to Mr. Xcoder 
```
.A.egb.O<Q
```
[Try it online!](https://tio.run/##K6gsyfj/X89RLzU9Sc/fJvD//2gTHQUIMjQyjgUA "Pyth – Try It Online")
[Answer]
# [Java (OpenJDK 8)](http://openjdk.java.net/), 96 bytes
I know it's not a good golfing language, but I still gave it a go!
Input array as first argument of comma separated ints to test.
Returns 1 for true, 0 for false.
```
a->{int i=1,j,r=1,s=0;for(;i<a.length;i++,s=0){for(j=0;j<i;s+=a[j++]);r=s/i>a[i]?0:r;}return r;}
```
[Try it online!](https://tio.run/##TZAxb4MwEIVn8ytOmUAkhK51SOcOjSp1RAzXxHFMwKCzSRUhfjs9o0Ttcvb53nv@dDXecNP1ytan63xs0Dn4QGPHKBLGekVnPCo4jBGI0IOOuZYVJjISE2v64bsxR3AePR@3zpygZXv85clYXVaAyRgJsd3CJ5JTDvxFwdmQ84Ckh1Zxpu8gRCMR3uHcESh0dxgcasXWvyTSDgrAMq8y1zfGx6v1KnCIBenhL8Cqn5BXBn3WKKv9pQoqTg7wYFiTSzC7fwJu03QhFUtMaSpWvfMCtKKsD@jcxMHBo4yR2jhZ/p4C4t151Wbd4LOeYX1sMx0vOclzT48FHcBy7oyb/bigFC/rek1cXZHLACgZ68nESOE9GcOgZkG9M9KlBZZ1mlaJpMJtzR4Z6C1/JTmR8gNZ4NssZDTNvw "Java (OpenJDK 8) – Try It Online")
]