blob: 7cb46de1db5abc8f8287f914756aef2f5a4f7158 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
from sys import stdin
a = [int(n) for n in stdin.readlines()]
p = list(range(len(a)))
for i, n in enumerate(a):
og_idx = p.index(i)
p.pop(og_idx)
og_idx = (og_idx + n) % len(p)
if og_idx == 0 and n < 0: og_idx = len(p)
p.insert(og_idx, i)
a = [a[i] for i in p]
def g(n): return a[(a.index(0) + n) % len(a)]
print(g(1000) + g(2000) + g(3000))
|