Your for loop is using a value taken from your values array as the count limit, but you are indexing myArray. As you stated in your comment, you are going outside your array bounds.
You should have:
for (int t = 0; t < myArray.Length; t++)
Your for loop is using a value taken from your values array as the count limit, but you are indexing myArray. As you stated in your comment, you are going outside your array bounds.
You should have:
for (int t = 0; t < myArray.Length; t++)