using System.Collections.Generic;
public static void Main()
int num = getSum(new List<int>() { 34, -50, 42, 14, -5, 86, -4, 5, 2, -1 });
public static int getSum(List<int> list)
for(int i = 0; i < list.Count; i++)
if (i == list.Count - 1 && list[i] < 0)
currentSum = currentSum + list[i];
if(currentSum - list[i] <= 0 )