public class Solution { public int LargestPerimeter(int[] A) { var list = A.OrderByDescending(x => x).ToList(); var length = list.Count; if (length < 3) { return 0; } for (int i = 0; i <= length - 3; i++) { //Console.WriteLine(i); var list2 = list.Skip(i).Take(3).ToList(); var a = list2[0]; var b = list2[1]; var c = list2[2]; if (a < b + c && b < a + c && c < a + b) { return a + b + c; } } return 0; } }