Array index out of range after build

Hello, In editor works good but after build there is error IndexOutOfRangeException: Index was outside the bounds of the array.

                int rand = Random.Range(0, (cars.Length));
                vehicle = Instantiate(cars[rand]);

I tried with cars.length-1 too but not working. There is only one element in cars array but will be more but at this time I want to make it works with one element in the array.
Why in editor it works but not after build?

Please can anyone help me with arrays which resets after build with no reason?