C # program for the above approach
using System ; using System . Collections . Generic ; class GFG { static void Main ( ) { int [ ] arr = { 10 , 2 , - 2 , - 20 , 10 } ; int k = - 10 ; int n = arr . Length ; int res = 0 ;