title: Select first k elements in C# LINQ such that the sum of elements is less than S
body: <p>I have an array of numbers and a variable S. I want to select first k elements out of them using LINQ in C# such that the sum of k elements is less than S.</p>
  
  <p>For example:</p>
  
  <p>int[] Numbers = { 1, 4, 53, 23, 15, 12, 15, 25, 45, 13, 16, 76, 43, 82, 24 };
  int S = 100;</p>
  
  <p>The result would be an array: {1, 4, 53, 23, 15}</p>