Definition

Narcissistic 1 integers of an array think they are better than their neighbours, because they are strictly higher than their arithmetic mean.

Neighbours are defined as follows:

• If the integer is at index 0 (the first), then its neighbours are the last and the second elements of the list.

• If the integer is not the first nor the last, then its neighbours are the two immediately adjacent elements.

• If the integer is at index -1 (the last), then its neighbours are the second-last and the first elements of the list.

• The integers can be positive, negative or zero.

• You may assume that the array contains at least three elements.

• All standard rules apply. This is , so the shortest code in bytes wins.

Examples

Consider the array [6, 9, 4, 10, 16, 18, 13]. Then we can built the following table:

Element | Neighbours | Neighbours' Mean | Is Narcissistic?
--------+------------+------------------+-----------------
6       | 13, 9      | 11               | False.
9       | 6, 4       | 5                | True.
4       | 9, 10      | 9.5              | False.
10      | 4, 16      | 10               | False.
16      | 10, 18     | 14               | True.
18      | 16, 13     | 14.5             | True.
13      | 18, 6      | 12               | True.

By filtering the Narcissistic ones out, we are left with [6, 4, 10]. And that's it!

Test Cases

Input -> Output

[5, -8, -9]                         -> [-8, -9]
[8, 8, 8, 8]                        -> [8, 8, 8, 8]
[11, 6, 9, 10]                      -> [6, 10]
[1, 2, 0, 1, 2]                     -> [1, 0, 1]
[6, 9, 4, 10, 16, 18, 13]           -> [6, 4, 10]
[6, -5, 3, -4, 38, 29, 82, -44, 12] -> [-5, -4, 29, -44]

1 - Narcissist does not mean mathematically Narcissistic.

Jelly, 10 bytes

ṙ2+ṙ-<ḤCx@

Try it online!

Explanation:

ṙ2+ṙ-<ḤCx@
ṙ2         Rotate the original list two elements to the left
+        Add each element to the respective element of the original list
ṙ-      Rotate the result one element to the right
<Ḥ    Check if each element is less than the double of its respective element on the original list
C   Subtract each 1/0 boolean from 1 (logical NOT in this case)
x@ Repeat each element of the original list as many times as the respective element of the logical NOT (i.e. keep elements of the original list where the respective element from the result is 1)

Python 2, 60 bytes

lambda x:[b for a,b,c in zip(x[-1:]+x,x,x[1:]+x)if b*2<=a+c]

Try it online!

JavaScript (ES6), 57 56 bytes

a=>a.filter((e,i)=>e+e<=a[(i||l)-1]+a[++i%l],l=a.length)

Edit: Saved 1 byte thanks to @g00glen00b.

Mathematica, 44 bytes

Pick[#,#<=0&/@(2#-(r=RotateLeft)@#-#~r~-1)]&

How it works

Given input such as {11,6,9,10}, computes

2*{11,6,9,10} - {6,9,10,11} - {10,11,6,9}

and picks out the elements of the original input in places where this result is at most 0.

05AB1E, 221715 14 bytes

vy¹®1‚N+èO;>‹—

Try it online!

vy             # For each...
¹            # Push array.
®1‚         # Push [1,-1]
è      # Push surrounding values of current index.
O;    # Summed in half.
>‹  # A <= B?
— # If true, print current.

f s=[b|(a,b,c)<-zip3(last s:s)s$tail$s++s,b*2<=a+c]