title: Array out of boundries
body: <p>I can't figure out why is the array out of its borders, eclipes says the problem is at  line 15 </p>
  
  <blockquote>
    <p>int d = array[1] - array[0];</p>
  </blockquote>
  
  <pre><code>import java.util.*;
  
  public class Arrays1 {
      static Scanner reader = new Scanner(System.in);
  
      public static void main(String[] args) {
          int N = reader.nextInt();
          int[] array = new int[N];
          boolean right = true;
          for (int i=0; i&lt;array.length; i++)
          {
              System.out.println("Enter number for array");
              array[i] = reader.nextInt();
          }
          int d = array[1] - array[0];
          if ((array[N]-1)%d !=0)
          {
              right = false;
          }
      }
  
  }
  </code></pre>