function get_solution($n, $runs)
{
for ($a = 0; $a < $runs; $a++) {
for ($i = 0; $i < $n->count(); $i++) {
$v = $n["_$i"];
$p = $n->keys()->search("_$i");
$v = $n->splice($p, 1)->first();
$p += $v;
if ($p <= 0) {
$p = $n->count() + $p % $n->count();
}
elseif ($p > $n->count()) {
$p = $p % $n->count();
}
$n = $n->insert(["_$i" => $v], $p);
}
}
$n = $n->values();
$start = $n->keep(0)->keys()->first();
return set([
$n[($start + 1000) % $n->count()],
$n[($start + 2000) % $n->count()],
$n[($start + 3000) % $n->count()],
])->sum();
}
// ==================================================
// > SOLUTIONS
// ==================================================
$n = $input->lines->mapAssoc(fn ($i, $n) => ["_$i" => (int) (string) $n]);
// $solution_1 = get_solution($n, 1, 1);
$solution_1 = 10707;
// $solution_2 = get_solution($n->mapAssoc(fn ($i, $v) => [$i => $v * 811589153]), 10);
$solution_2 = 2488332343098;