def grid_count(grid, X):
    """Counts the number of elements on a grid."""
    del_elems = X < grid[0]
    remaining_X = X[~del_elems]
    res = list()
    for thre in grid[1:]:
        del_elems = remaining_X < thre
        remaining_X = X[~del_elems]
        res.append(del_elems.sum())
    return res