title: finding longest sequence of consecutive numbers
body: <p>Problem H (Longest Natural Successors):</p>
  
  <p>Two consecutive integers are natural successors if the second is the successor of the first in the sequence of natural numbers (1 and 2 are natural successors). Write a program that reads a number N followed by N integers, and then prints the length of the longest sequence of consecutive natural successors.</p>
  
  <p>Example:</p>
  
  <p>Input 7 2 3 5 6 7 9 10 Output 3 this is my code so far and i have no idea why it does not work</p>
  
  <pre><code>import java.util.Scanner;
  
  public class Conse {
  
      public static void main(String[] args) {
          Scanner scan = new Scanner(System.in);
          int x = scan.nextInt();
          int[] array = new int[x];
          for (int i = 0; i &lt; array.length; i++) {
              array[i] = scan.nextInt();
          }
          System.out.println(array(array));
  
      }
  
      public static int array(int[] array) {
          int count = 0, temp = 0;
          for (int i = 0; i &lt; array.length; i++) {
              count = 0;
              for (int j = i, k = i + 1; j &lt; array.length - 1; j++, k++) {
                  if (Math.abs(array[j] - array[k]) == 1) {
                      count++;
                  } else {
                      if (temp &lt;= count) {
                          temp = count;
                      }
                      break;
                  }
              }
          }
          return temp + 1;
      }
  
  }
  </code></pre>