Fetch the three entries before, and after, a given Structure entry, with wrapping
Assuming that when you are on the first page, you don't show the last 3 entries of your structure and the single array you need is an array of entries, this should do it for you:

{# Set how many entries to have around current entry #}
{% set surroundingEntries = 3 %}

{# Fetch prev 3 entries - reverse order because of limit() #}
{% set prevEntries = craft.entries.positionedBefore(entry).orderBy('lft desc').limit(surroundingEntries).all() %}

{# Fetch next 3 entries #}
{% set nextEntries = craft.entries.positionedAfter(entry).limit(surroundingEntries).all() %}

{# if there aren't enough nextEntries, add some #}
{% if nextEntries|length &lt; surroundingEntries %}
    {% set limit = surroundingEntries - nextEntries|length %}
    {% set extraEntries = craft.entries.section('sectionName').limit(limit).all() %}
    {% set nextEntries = nextEntries|merge(extraEntries) %}
{% endif %}

{# Put prevEntries back in order and merge nextEntries to it #}
{% set results = prevEntries | reverse | merge(nextEntries) %}


If you need an array of ids, replace .all() with .ids() and if I misunderstood you and  you need two separate arrays, simply don't merge them as results and use nextEntries / prevEntries but don't forget to |reverse your prevEntries to get them back in order :)