How to Fix Index out of Range. My game is to open the door with key with the use of array.

using UnityEngine;
using System.Collections;

public class Interact : MonoBehaviour {

public float interactDistance = 3f;

// Update is called once per frame
void Update () {
	if (Input.GetKeyDown (KeyCode.Mouse0)) 
	{
		Ray ray = new Ray (transform.position, transform.forward);
		RaycastHit hit;
		if (Physics.Raycast (ray, out hit, interactDistance)) 
		{
			if (hit.collider.CompareTag ("Door")) {
                Door door = hit.collider.transform.parent.GetComponent<Door>();

                if (door == null) return;

                if (Inventory.keys[door.index] == true) //THIS CODE IT SAYS INDEX OUT OF RANGED.
                {
                   door.ChangeDoorState ();
                }
			} 
		}
	}


}

}

IN MY ANOTHER SCRIPT I HAVE A VARIABLE
public int index = -1;

ANOTHER SCRIPT CONTAINS THE DECLARATION OF ARRAY
public static bool keys = new bool[10];

// 10 IS THE NUMBER OF DOORS

Arrays don’t start out at a negative number.

So if you’re trying to access the 10th door, it’d be keys[9].

Arrays start off at [0].