Failed to execute script at block

import * as fcl from “@onflow/fcl”;

import * as t from “@onflow/types”;

export const LatestListing = async () => {

const script = `import NFTStorefront from 0x4fc019cea9fc4817

pub fun main(set : UInt64) : [UInt64]{

    var end = UInt64(0)

    var n = UInt64(NFTStorefront.allIdsForTimeStamps.length - 1)

    var start = n - ((set-1) * 10)

    if n >= set*10 {

        end = n - (set *10) + 1

    } else {

        end = start - n%10

    }

    

    let timearr : [UInt64] = []

    

    while start >= end {

        timearr.append(NFTStorefront.allIdsForTimeStamps[start])

        if start == 0 {

            break

        }

        start = start - 1 

    }

    

    return timearr;

}`

try {

    const response = await fcl.send([

        fcl.script`${script}`,

        fcl.args([

            fcl.arg(1, t.UInt64)

        ]),

        fcl.limit(100)

    ])

    console.log("res", await fcl.decode(response))

    return await fcl.decode(response)

} catch (e) {

    console.log('error', e)

}

}

this is giving an error
rpc error: code = Internal desc = failed to execute script: failed to execute script at block (e5e930e498c0fa0e48eca89fd01c7022d656d5ec4be6c97b14e9859447bd0a58): [Error Code: 1101] cadence runtime error Execution failed:
error: underflow

I am using testnet.
Please help

It looks like you have an underflow somewhere, which means that you are trying to create a number that is below the minimum representation for the type you are using (UInt64). I would take a look at your arithmetic operations to make sure that is happening, or if you intend to have a negative number, use Int64 instead.