# Definition

An **_element is leader_** *if it is greater than The Sum all the elements to its right side*.
____

# Task

**_Given_** an *array/list [] of integers* , **_Find_** *all the **_LEADERS_** in the array*.
___

# Notes 

* **_Array/list_** size is *at least 3* .

* **_Array/list's numbers_**  Will be **_mixture of positives , negatives and  zeros_** 

* **_Repetition_** of numbers in *the array/list could occur*.

* **_Returned Array/list_** *should store the leading numbers **_in the same order_** in the original array/list* .
___

# Input >> Output Examples 


```
arrayLeaders ({1, 2, 3, 4, 0}) ==> return {4}
```

## **_Explanation_**: 

* `4`  *is greater than the sum all the elements to its right side*

* **_Note_** : **_The last element_** `0`  *is equal to right sum of its elements (abstract zero)*.
____

```
arrayLeaders ({16, 17, 4, 3, 5, 2}) ==> return {17, 5, 2}
```

## **_Explanation_**: 

* `17`  *is greater than the sum all the elements to its right side*

* `5`  *is greater than the sum all the elements to its right side*

* **_Note_** : **_The last element_**  `2`  *is  greater than the sum of its right elements (abstract zero)*. 
___

```
arrayLeaders ({5, 2, -1}) ==> return {5, 2}
```

## **_Explanation_**: 

* `5`  *is greater than the sum all the elements to its right side*

* `2`  *is greater than the sum all the elements to its right side*

* **_Note_** : **_The last element_**  `-1`  *is less than the sum of its right elements (abstract zero)*.

___

```
arrayLeaders ({0, -1, -29, 3, 2}) ==> return {0, -1, 3, 2}
```

## **_Explanation_**: 

* `0`  *is greater than the sum all the elements to its right side*

* `-1`  *is greater than the sum all the elements to its right side*

* `3`  *is greater than the sum all the elements to its right side*

* **_Note_** : **_The last element_**  `2`  *is  greater than the sum of its right elements (abstract zero)*.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def array_leaders(numbers):
	

Solutions:
def array_leaders(numbers):
	return [n for (i, n) in enumerate(numbers) if n > sum(numbers[i + 1:])]


def array_leaders(numbers):
	res = []
	s = 0
	for n in reversed(numbers):
		if n > s:
			res.append(n)
		s += n
	res.reverse()
	return res
arrayLeaders = array_leaders


def array_leaders(numbers):
	return [j for (i, j) in enumerate(numbers) if j > sum(numbers[i + 1:])]


def array_leaders(numbers):
	nums = numbers + [0]
	return [a for (c, a) in enumerate(nums, 1) if a > sum(nums[c:])]


array_leaders = lambda n: [e for (i, e) in enumerate(n, 1) if e > sum(n[i:])]


def array_leaders(num):
	return [n for (i, n) in enumerate(num, 1) if n > sum(num[i:])]


def array_leaders(numbers):
	a = []
	numbers.append(0)
	for i in range(len(numbers)):
		if numbers[i] > sum(numbers[i + 1:]):
			a.append(numbers[i])
	return a


def array_leaders(numbers):
	res = []
	s = 0
	for n in reversed(numbers):
		if n > s:
			res.append(n)
		s += n
	return list(reversed(res))


def array_leaders(n):
	leaders = []
	for i in range(len(n) - 1, -1, -1):
		if n[i] > sum(n[i + 1:]):
			leaders.append(n[i])
	leaders.reverse()
	return leaders


def array_leaders(numbers):
	(result, sum) = ([], 0)
	for i in range(len(numbers)):
		if numbers[-i - 1] > sum:
			result.insert(0, numbers[-i - 1])
		sum += numbers[-i - 1]
	return result


from itertools import accumulate

def array_leaders(numbers):
	if numbers[-1]:
		numbers.append(0)
	return [numbers[-i] for (i, x) in enumerate(accumulate(numbers[:0:-1]), 2) if numbers[-i] > x][::-1]


def array_leaders(numbers):
	return [item for (ind, item) in enumerate(numbers) if item > sum(numbers[ind + 1:])]


def array_leaders(numbers):
	sum = 0
	(i, l) = (1, len(numbers))
	leaders = []
	while i <= l:
		if numbers[-i] > sum:
			leaders = [numbers[-i]] + leaders
		sum += numbers[-i]
		i += 1
	return leaders


def array_leaders(numbers):
	return [x for (i, x) in enumerate(numbers) if x > sum(numbers[i + 1:])]


def array_leaders(numbers):
	return [numbers[i] for i in range(len(numbers)) if numbers[i] > sum(numbers[i + 1:])]


array_leaders = lambda a: [a[i] for i in range(len(a)) if a[i] > sum(a[i + 1:])]


def array_leaders(numbers):
	return [element for (index, element) in enumerate(numbers) if element > sum(numbers[index + 1:])]


def array_leaders(numbers):
	return [i for (index, i) in enumerate(numbers, 1) if sum(numbers[index:]) < i]


def array_leaders(numbers):
	arr = []
	for i in range(len(numbers) - 1):
		if numbers[i] > sum(numbers[i + 1:]):
			arr.append(numbers[i])
	return arr + [numbers[-1]] if not numbers[-1] <= 0 else arr


def array_leaders(arr):
	return [arr[x] for x in range(len(arr)) if arr[x] > sum(arr[x + 1:])]


def array_leaders(numbers):
	right = 0
	out = []
	for x in numbers[::-1]:
		if x > right:
			out.append(x)
		right += x
	return out[::-1]


def array_leaders(nums):
	return [nums[i] for i in range(len(nums)) if nums[i] > sum(nums[i + 1:])]


def array_leaders(numbers):
	n = 0
	out = []
	for i in reversed(numbers):
		if i > n:
			out.append(i)
		n += i
	out.reverse()
	return out


def array_leaders(numbers):
	n = sum(numbers)
	out = []
	for i in numbers:
		n -= i
		if i > n:
			out.append(i)
	return out


def array_leaders(numbers):
	s = sum(numbers)
	mx = []
	for i in range(len(numbers)):
		if numbers[i] > sum(numbers[i + 1:]):
			mx.append(numbers[i])
	return mx


def array_leaders(numbers):
	return [elem for (idx, elem) in enumerate(numbers) if elem > sum(numbers[idx + 1:])]


def array_leaders(numbers):
	i = 0
	output = []
	for num in numbers:
		sum_right = sum(numbers[i + 1:len(numbers)])
		if sum_right < num:
			output.append(num)
		else:
			pass
		i += 1
	return output


def array_leaders(numbers):
	john = []
	for (i, v) in enumerate(numbers):
		if v > sum(numbers[i + 1:]):
			john.append(v)
	return john


def array_leaders(numbers):
	(out, s) = ([], 0)
	for i in reversed(range(len(numbers))):
		if numbers[i] > s:
			out.insert(0, numbers[i])
		s += numbers[i]
	return out


def array_leaders(numbers):
	r = []
	s = sum(numbers)
	for x in numbers:
		s -= x
		if x > s:
			r.append(x)
	return r


def array_leaders(N):
	return [n for (i, n) in enumerate(N) if n > sum(N[i + 1:])]


def array_leaders(nums):
	(total, res) = (sum(nums), [])
	for x in nums:
		total -= x
		if x > total:
			res.append(x)
	return res


def array_leaders(numbers):
	accum = 0
	leaders = []
	for n in reversed(numbers):
		if n > accum:
			leaders.append(n)
		accum += n
	leaders.reverse()
	return leaders


def array_leaders(numbers):
	return [el for (i, el) in enumerate(numbers) if el > sum(numbers[i + 1:])]


def array_leaders(numbers):
	res = []
	for i in range(len(numbers)):
		if numbers[i] > sum((x for x in numbers[i + 1:])):
			res.append(numbers[i])
	return res


from collections import deque

def array_leaders(numbers):
	res = deque([])
	sm = 0
	i = len(numbers) - 1
	while i >= 0:
		n = numbers[i]
		if n > sm:
			res.appendleft(n)
		sm += n
		i -= 1
	return list(res)


def array_leaders(numbers):
	rl = []
	sarr = sum(numbers)
	for num in numbers:
		sarr -= num
		if num > sarr:
			rl.append(num)
	return rl


def array_leaders(numbers):
	return [val for (ind, val) in enumerate(numbers) if val > sum(numbers[ind + 1:])]


def array_leaders(numbers):
	lsum = 0
	res = []
	tsum = sum(numbers)
	for i in numbers:
		lsum += i
		if i > tsum - lsum:
			res.append(i)
	return res


def array_leaders(numbers):
	length = len(numbers)
	numbers.append(0)
	res = []
	for i in range(length):
		if numbers[i] > sum(numbers[i + 1:]):
			res.append(numbers[i])
	return res


def array_leaders(numbers):
	return [numbers[x] for x in range(len(numbers)) if sum(numbers[x + 1:]) < numbers[x]]


def array_leaders(n):
	return [n[i] for i in range(len(n)) if sum(n[i + 1:]) < n[i]]


def array_leaders(numbers):
	res = []
	for (pos, val) in enumerate(numbers):
		if val > sum(numbers[pos + 1:]):
			res.append(val)
	return res


def array_leaders(numbers):
	return [v for (i, v) in enumerate(numbers) if v > sum(numbers[i:]) - v]


def array_leaders(numbers):
	leaders = []
	for i in range(len(numbers) - 1):
		if numbers[i] > sum(numbers[i + 1:-1]) + numbers[-1]:
			leaders.append(numbers[i])
		else:
			continue
	if numbers[-1] > 0:
		leaders.append(numbers[-1])
	return leaders


def array_leaders(numbers):
	return [n for (c, n) in enumerate(numbers, 1) if n > sum(numbers[c:])]


def array_leaders(numbers):
	sum_tot = sum((i for i in numbers))
	sum_left = 0
	a = []
	for i in numbers:
		sum_left += i
		if i > sum_tot - sum_left:
			a.append(i)
	return a


def array_leaders(numbers):
	return [k for (i, k) in enumerate(numbers) if sum(numbers[i + 1:]) < k]


def array_leaders(numbers):
	if len(numbers) < 3:
		return numbers
	n = []
	for i in range(len(numbers)):
		if int(numbers[i]) > sum(numbers[i + 1:]):
			n.append(numbers[i])
	return n


def array_leaders(numbers):
	res = []
	for (i, value) in enumerate(numbers):
		if numbers[i] > sum(numbers[i + 1:]):
			res.append(value)
	return res


def array_leaders(numbers):
	return [number for (i, number) in enumerate(numbers) if numbers[i] > sum(numbers[i + 1:len(numbers)])]


def array_leaders(numbers):
	final_list = []
	for item in range(len(numbers)):
		if numbers[item] > sum(numbers[item + 1:]):
			final_list.append(numbers[item])
	return final_list


def array_leaders(numbers):
	return [x for (pos, x) in enumerate(numbers) if x > sum(numbers[pos + 1:])]


def array_leaders(numbers):
	(count, res) = (0, [])
	while count < len(numbers):
		if len(numbers[count + 1:]) >= 0:
			if numbers[count] > sum(numbers[count + 1:]):
				print(numbers[count])
				res.append(numbers[count])
		count += 1
	return res


def array_leaders(numbers):
	li = []
	for s in range(len(numbers) * -1, 0):
		if s == -1:
			if numbers[-1] > 0:
				li.append(numbers[s])
			else:
				break
		elif sum(numbers[s + 1:]) <= numbers[s]:
			li.append(numbers[s])
		else:
			continue
	return li


def array_leaders(numbers):
	kl = []
	rnumbers = numbers[::-1]
	for i in range(len(numbers)):
		if numbers[i] > sum(rnumbers[:-(i + 1)]):
			kl.append(numbers[i])
	return kl


from typing import List

def array_leaders(numbers: List[int]) -> List[int]:
	(leaders, s) = ([], sum(numbers))
	for n in numbers:
		s -= n
		if n > s:
			leaders.append(n)
	return leaders


def array_leaders(numbers):
	leaders = []
	while numbers:
		if numbers[0] > sum(numbers) - numbers[0]:
			leaders.append(numbers[0])
		numbers.remove(numbers[0])
	return leaders


from itertools import accumulate
from operator import add

def array_leaders(lst):
	r = list(accumulate(lst, add))
	return [n for (i, n) in enumerate(lst) if r[-1] - r[i] < n]


def array_leaders(numbers):
	return [x for (index, x) in enumerate(numbers) if x > sum(numbers[index + 1:])]


def array_leaders(numbers):
	sum = 0
	lst = list()
	numbers = numbers[::-1]
	for i in numbers:
		if i > sum:
			lst.append(i)
		sum += i
	return lst[::-1]


def array_leaders(n):
	return list((x for (i, x) in enumerate(n) if x > sum(n[i + 1:])))


def array_leaders(numbers):
	i = len(numbers) - 1
	tot = 0
	ans = []
	while i >= 0:
		if numbers[i] > tot:
			ans.append(numbers[i])
		tot = tot + numbers[i]
		i = i - 1
	return ans[::-1]


def array_leaders(numbers):
	rightsum = 0
	i = len(numbers) - 1
	leaders = []
	while i > -1:
		if numbers[i] > rightsum:
			leaders.append(numbers[i])
		rightsum += numbers[i]
		i -= 1
	leaders.reverse()
	return leaders


def array_leaders(numbers):
	return [i for (ind, i) in enumerate(numbers) if i > sum(numbers[ind + 1:])]


def array_leaders(numbers):
	res_list = []
	i = 0
	while i < len(numbers) - 1:
		if numbers[i] > sum(numbers[i + 1:]):
			res_list.append(numbers[i])
		i += 1
	if numbers[len(numbers) - 1] > 0:
		res_list.append(numbers[len(numbers) - 1])
	return res_list


def array_leaders(numbers):
	sum_right = 0
	result = []
	for num in reversed(numbers):
		if num > sum_right:
			result.append(num)
		sum_right += num
	return result[::-1]


def array_leaders(numbers):
	results = []
	for (i, n) in enumerate(numbers):
		if i < len(numbers) - 1 and sum(numbers[i + 1:]) < n:
			results.append(n)
		elif i == len(numbers) - 1 and n > 0:
			results.append(n)
	return results