int sum = 1; for (int i = 0; i <= 5; sum = sum + i++); System.out.print(sum) 





For example:
Input array: 3, 7, 8, 5, 4, 9 Method returns 3, because: 3, 7, 8, 5, 4, 9 3, 7, 8, 5, 4, 9 3, 7, 8, 5, 4, 9 