title: C#: loop through array of numbers and put consecutive numbers in one array, and all other numbers else in other array
body: <p>I have an unsorted array of numbers. Most numbers in this array are consecutive (1, 2, 3, 4, 5,...) but sometimes there's a number in it that's higher than the rest.  </p>
  
  <pre><code>int highestNumber = int.MinValue;
  int secondHighestNumber = int.MinValue;
  
  int[] arr = new int[] { 1, 2, 3, 4, 5, 6, 1207, 7, 8, 9, 1803, 10, 11, , 9000, 9001 };
  int counter = 0;
  
  foreach (int number in arr) {
      if (number &gt; highestNumber) {
          secondHighestNumber = highestNumber;
          highestNumber = number;
      }
      else if (number &gt; secondHighestNumber) secondHighestNumber = number;
  }
  </code></pre>
  
  <p>When I run the code, it'll tell me 9001 is the highest number and 9000 the second highest. But I want to change it so that I get an array of all the numbers from 1 to 11, with all the consecutive numbers <em>that only have a difference of one</em>, and a second array with all the larger numbers: 1207, 1803, 9000 and 9001.<br>
  9000 and 9001 shouldn't be in the first array, because the difference between these numbers and the rest is too high. So the end result should look like this:</p>
  
  <pre><code>int[] arr1 = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
  int[] arr2 = new int[] { 1207, 1803, 9000, 9001 };
  </code></pre>
  
  <p>Some background info on what the purpose of this is:<br>
  Cient creates articles and each article has an article number that is created by looking up what the highest article number is in the "articles" table so far (e.g. 20), then the number of the new article is that number + 1 (e.g. 21); So an increment per number. However the client wishes to be able to sometimes add articles and input the article number he desires for the article, so let's say for the last article he created he inputted 7000 as article number. If he he then creates another article after that, I have to continue with that list of incrementing numbers. So unless the client changes the value of the next article again, the next new article should have 22 as article number (and not 7001).  </p>
  
  <p>Any help would be greatly appreciated as I've been stuck on trying to figure this out for a while now. </p>