Index was outside the bounds of the array help

So this is my current code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Gameboard : MonoBehaviour
{
    private static int boardWidth = 17;
    private static int boardHeight = 17;
   
    public GameObject[,] board = new GameObject[boardWidth, boardHeight]; // stores x and y of each node in relation to board size
    // Start is called before the first frame update
    void Start()
    {
        Object[] objects = GameObject.FindObjectsOfType(typeof(GameObject)); // finds all nodes and stores in an array
       
        foreach (GameObject o in objects) { // loops for each node
            Vector3 pos = o.transform.position; // finds position of each node

            if (o.name != "Pacman") { // checks that they aren't nodes
                board [(int)pos.x, (int)pos.y] = o; // stores x and y position of each node that isn't pacman in board array
            }
            else {
                Debug.Log ("Found Pacman at: " + pos);
            }
        }
    }

    // Update is called once per frame
    void Update()
    {
       
    }
}

But when i try to run unity, i get this error:

IndexOutOfRangeException: Index was outside the bounds of the array.
Gameboard.Start () (at Assets/Scripts/Gameboard.cs:20)

Does anyone know what is wrong?

Thanks!

Use debug on your position. Make sure, xy are within 0-16 int range.