n = int(input())
a = list(map(int, input().split()))
prefix = []
for i, item in enumerate(a):
k = item
if i:
k += prefix[i-1]
prefix.append(k)
num = n-abs(max(prefix))
# l = n-min(prefix)
e, l = max(prefix), min(prefix);values = [];count = 0
for i in range(1, n+1):
if 1 <= i + e <= n and 1 <= i + l <= n:
values.append(i);count += 1
if count == 1:
result = [values[0]]
for i, item in enumerate(prefix):
result.append(result[0]+item)
print(*result)
else:
print(-1)
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2772 KB |
Output is correct |
2 |
Correct |
13 ms |
2872 KB |
Output is correct |
3 |
Correct |
13 ms |
2748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2772 KB |
Output is correct |
2 |
Correct |
13 ms |
2872 KB |
Output is correct |
3 |
Correct |
13 ms |
2748 KB |
Output is correct |
4 |
Correct |
14 ms |
2772 KB |
Output is correct |
5 |
Correct |
19 ms |
2828 KB |
Output is correct |
6 |
Correct |
13 ms |
2772 KB |
Output is correct |
7 |
Correct |
16 ms |
2820 KB |
Output is correct |
8 |
Correct |
13 ms |
2772 KB |
Output is correct |
9 |
Correct |
14 ms |
2860 KB |
Output is correct |
10 |
Correct |
13 ms |
2888 KB |
Output is correct |
11 |
Correct |
15 ms |
2836 KB |
Output is correct |
12 |
Correct |
13 ms |
2832 KB |
Output is correct |
13 |
Correct |
13 ms |
2772 KB |
Output is correct |
14 |
Correct |
13 ms |
2772 KB |
Output is correct |
15 |
Correct |
13 ms |
2876 KB |
Output is correct |
16 |
Correct |
13 ms |
2868 KB |
Output is correct |
17 |
Correct |
18 ms |
2840 KB |
Output is correct |
18 |
Correct |
14 ms |
2840 KB |
Output is correct |
19 |
Correct |
14 ms |
2848 KB |
Output is correct |
20 |
Correct |
16 ms |
2880 KB |
Output is correct |
21 |
Correct |
13 ms |
2772 KB |
Output is correct |
22 |
Correct |
13 ms |
2856 KB |
Output is correct |
23 |
Correct |
17 ms |
2800 KB |
Output is correct |
24 |
Correct |
13 ms |
2852 KB |
Output is correct |
25 |
Correct |
12 ms |
2868 KB |
Output is correct |
26 |
Correct |
14 ms |
2876 KB |
Output is correct |
27 |
Correct |
13 ms |
2772 KB |
Output is correct |
28 |
Correct |
13 ms |
2880 KB |
Output is correct |
29 |
Correct |
13 ms |
2876 KB |
Output is correct |
30 |
Correct |
13 ms |
2872 KB |
Output is correct |
31 |
Correct |
14 ms |
2772 KB |
Output is correct |
32 |
Correct |
19 ms |
2848 KB |
Output is correct |
33 |
Correct |
14 ms |
2832 KB |
Output is correct |
34 |
Correct |
16 ms |
2872 KB |
Output is correct |
35 |
Correct |
13 ms |
2880 KB |
Output is correct |
36 |
Correct |
13 ms |
2892 KB |
Output is correct |
37 |
Correct |
13 ms |
2844 KB |
Output is correct |
38 |
Correct |
14 ms |
2772 KB |
Output is correct |
39 |
Correct |
13 ms |
2800 KB |
Output is correct |
40 |
Correct |
14 ms |
2868 KB |
Output is correct |
41 |
Correct |
13 ms |
2876 KB |
Output is correct |
42 |
Correct |
17 ms |
2872 KB |
Output is correct |
43 |
Correct |
14 ms |
2900 KB |
Output is correct |
44 |
Correct |
17 ms |
2772 KB |
Output is correct |
45 |
Correct |
13 ms |
2872 KB |
Output is correct |
46 |
Correct |
13 ms |
2752 KB |
Output is correct |
47 |
Correct |
14 ms |
2796 KB |
Output is correct |
48 |
Correct |
13 ms |
2776 KB |
Output is correct |
49 |
Correct |
13 ms |
2768 KB |
Output is correct |
50 |
Correct |
14 ms |
2872 KB |
Output is correct |
51 |
Correct |
13 ms |
2880 KB |
Output is correct |
52 |
Correct |
15 ms |
2772 KB |
Output is correct |
53 |
Correct |
13 ms |
2772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2772 KB |
Output is correct |
2 |
Correct |
13 ms |
2872 KB |
Output is correct |
3 |
Correct |
13 ms |
2748 KB |
Output is correct |
4 |
Correct |
14 ms |
2772 KB |
Output is correct |
5 |
Correct |
19 ms |
2828 KB |
Output is correct |
6 |
Correct |
13 ms |
2772 KB |
Output is correct |
7 |
Correct |
16 ms |
2820 KB |
Output is correct |
8 |
Correct |
13 ms |
2772 KB |
Output is correct |
9 |
Correct |
14 ms |
2860 KB |
Output is correct |
10 |
Correct |
13 ms |
2888 KB |
Output is correct |
11 |
Correct |
15 ms |
2836 KB |
Output is correct |
12 |
Correct |
13 ms |
2832 KB |
Output is correct |
13 |
Correct |
13 ms |
2772 KB |
Output is correct |
14 |
Correct |
13 ms |
2772 KB |
Output is correct |
15 |
Correct |
13 ms |
2876 KB |
Output is correct |
16 |
Correct |
13 ms |
2868 KB |
Output is correct |
17 |
Correct |
18 ms |
2840 KB |
Output is correct |
18 |
Correct |
14 ms |
2840 KB |
Output is correct |
19 |
Correct |
14 ms |
2848 KB |
Output is correct |
20 |
Correct |
16 ms |
2880 KB |
Output is correct |
21 |
Correct |
13 ms |
2772 KB |
Output is correct |
22 |
Correct |
13 ms |
2856 KB |
Output is correct |
23 |
Correct |
17 ms |
2800 KB |
Output is correct |
24 |
Correct |
13 ms |
2852 KB |
Output is correct |
25 |
Correct |
12 ms |
2868 KB |
Output is correct |
26 |
Correct |
14 ms |
2876 KB |
Output is correct |
27 |
Correct |
13 ms |
2772 KB |
Output is correct |
28 |
Correct |
13 ms |
2880 KB |
Output is correct |
29 |
Correct |
13 ms |
2876 KB |
Output is correct |
30 |
Correct |
13 ms |
2872 KB |
Output is correct |
31 |
Correct |
14 ms |
2772 KB |
Output is correct |
32 |
Correct |
19 ms |
2848 KB |
Output is correct |
33 |
Correct |
14 ms |
2832 KB |
Output is correct |
34 |
Correct |
16 ms |
2872 KB |
Output is correct |
35 |
Correct |
13 ms |
2880 KB |
Output is correct |
36 |
Correct |
13 ms |
2892 KB |
Output is correct |
37 |
Correct |
13 ms |
2844 KB |
Output is correct |
38 |
Correct |
14 ms |
2772 KB |
Output is correct |
39 |
Correct |
13 ms |
2800 KB |
Output is correct |
40 |
Correct |
14 ms |
2868 KB |
Output is correct |
41 |
Correct |
13 ms |
2876 KB |
Output is correct |
42 |
Correct |
17 ms |
2872 KB |
Output is correct |
43 |
Correct |
14 ms |
2900 KB |
Output is correct |
44 |
Correct |
17 ms |
2772 KB |
Output is correct |
45 |
Correct |
13 ms |
2872 KB |
Output is correct |
46 |
Correct |
13 ms |
2752 KB |
Output is correct |
47 |
Correct |
14 ms |
2796 KB |
Output is correct |
48 |
Correct |
13 ms |
2776 KB |
Output is correct |
49 |
Correct |
13 ms |
2768 KB |
Output is correct |
50 |
Correct |
14 ms |
2872 KB |
Output is correct |
51 |
Correct |
13 ms |
2880 KB |
Output is correct |
52 |
Correct |
15 ms |
2772 KB |
Output is correct |
53 |
Correct |
13 ms |
2772 KB |
Output is correct |
54 |
Correct |
16 ms |
2980 KB |
Output is correct |
55 |
Correct |
19 ms |
2904 KB |
Output is correct |
56 |
Correct |
19 ms |
3028 KB |
Output is correct |
57 |
Correct |
18 ms |
2880 KB |
Output is correct |
58 |
Correct |
17 ms |
2976 KB |
Output is correct |
59 |
Correct |
15 ms |
2956 KB |
Output is correct |
60 |
Correct |
15 ms |
3028 KB |
Output is correct |
61 |
Correct |
14 ms |
2900 KB |
Output is correct |
62 |
Correct |
15 ms |
2980 KB |
Output is correct |
63 |
Correct |
15 ms |
3028 KB |
Output is correct |
64 |
Correct |
15 ms |
3028 KB |
Output is correct |
65 |
Correct |
15 ms |
2952 KB |
Output is correct |
66 |
Correct |
14 ms |
3028 KB |
Output is correct |
67 |
Correct |
14 ms |
3048 KB |
Output is correct |
68 |
Correct |
15 ms |
3028 KB |
Output is correct |
69 |
Correct |
22 ms |
3028 KB |
Output is correct |
70 |
Correct |
20 ms |
3028 KB |
Output is correct |
71 |
Correct |
15 ms |
2900 KB |
Output is correct |
72 |
Correct |
15 ms |
2900 KB |
Output is correct |
73 |
Correct |
15 ms |
3028 KB |
Output is correct |
74 |
Correct |
15 ms |
2936 KB |
Output is correct |
75 |
Correct |
15 ms |
3064 KB |
Output is correct |
76 |
Correct |
15 ms |
3028 KB |
Output is correct |
77 |
Correct |
14 ms |
3008 KB |
Output is correct |
78 |
Correct |
14 ms |
3028 KB |
Output is correct |
79 |
Correct |
16 ms |
2988 KB |
Output is correct |
80 |
Correct |
16 ms |
3000 KB |
Output is correct |
81 |
Correct |
16 ms |
3156 KB |
Output is correct |
82 |
Correct |
15 ms |
3052 KB |
Output is correct |
83 |
Correct |
14 ms |
2880 KB |
Output is correct |
84 |
Correct |
14 ms |
2876 KB |
Output is correct |
85 |
Correct |
14 ms |
2876 KB |
Output is correct |
86 |
Correct |
15 ms |
2968 KB |
Output is correct |
87 |
Correct |
14 ms |
2960 KB |
Output is correct |
88 |
Correct |
14 ms |
2892 KB |
Output is correct |
89 |
Correct |
14 ms |
3028 KB |
Output is correct |
90 |
Correct |
15 ms |
3004 KB |
Output is correct |
91 |
Correct |
14 ms |
2900 KB |
Output is correct |
92 |
Correct |
15 ms |
2880 KB |
Output is correct |
93 |
Correct |
13 ms |
2944 KB |
Output is correct |
94 |
Correct |
14 ms |
2876 KB |
Output is correct |
95 |
Correct |
15 ms |
2868 KB |
Output is correct |
96 |
Correct |
14 ms |
2772 KB |
Output is correct |
97 |
Correct |
14 ms |
2772 KB |
Output is correct |
98 |
Correct |
16 ms |
3000 KB |
Output is correct |
99 |
Correct |
14 ms |
2804 KB |
Output is correct |
100 |
Correct |
16 ms |
3008 KB |
Output is correct |
101 |
Correct |
15 ms |
3008 KB |
Output is correct |
102 |
Correct |
16 ms |
2988 KB |
Output is correct |
103 |
Correct |
13 ms |
2860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
442 ms |
34160 KB |
Output is correct |
2 |
Correct |
14 ms |
2808 KB |
Output is correct |
3 |
Correct |
458 ms |
34332 KB |
Output is correct |
4 |
Correct |
339 ms |
19940 KB |
Output is correct |
5 |
Correct |
347 ms |
30920 KB |
Output is correct |
6 |
Correct |
308 ms |
23796 KB |
Output is correct |
7 |
Correct |
288 ms |
23512 KB |
Output is correct |
8 |
Correct |
363 ms |
27168 KB |
Output is correct |
9 |
Correct |
14 ms |
2884 KB |
Output is correct |
10 |
Correct |
13 ms |
2772 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
2772 KB |
Output is correct |
2 |
Correct |
13 ms |
2872 KB |
Output is correct |
3 |
Correct |
13 ms |
2748 KB |
Output is correct |
4 |
Correct |
14 ms |
2772 KB |
Output is correct |
5 |
Correct |
19 ms |
2828 KB |
Output is correct |
6 |
Correct |
13 ms |
2772 KB |
Output is correct |
7 |
Correct |
16 ms |
2820 KB |
Output is correct |
8 |
Correct |
13 ms |
2772 KB |
Output is correct |
9 |
Correct |
14 ms |
2860 KB |
Output is correct |
10 |
Correct |
13 ms |
2888 KB |
Output is correct |
11 |
Correct |
15 ms |
2836 KB |
Output is correct |
12 |
Correct |
13 ms |
2832 KB |
Output is correct |
13 |
Correct |
13 ms |
2772 KB |
Output is correct |
14 |
Correct |
13 ms |
2772 KB |
Output is correct |
15 |
Correct |
13 ms |
2876 KB |
Output is correct |
16 |
Correct |
13 ms |
2868 KB |
Output is correct |
17 |
Correct |
18 ms |
2840 KB |
Output is correct |
18 |
Correct |
14 ms |
2840 KB |
Output is correct |
19 |
Correct |
14 ms |
2848 KB |
Output is correct |
20 |
Correct |
16 ms |
2880 KB |
Output is correct |
21 |
Correct |
13 ms |
2772 KB |
Output is correct |
22 |
Correct |
13 ms |
2856 KB |
Output is correct |
23 |
Correct |
17 ms |
2800 KB |
Output is correct |
24 |
Correct |
13 ms |
2852 KB |
Output is correct |
25 |
Correct |
12 ms |
2868 KB |
Output is correct |
26 |
Correct |
14 ms |
2876 KB |
Output is correct |
27 |
Correct |
13 ms |
2772 KB |
Output is correct |
28 |
Correct |
13 ms |
2880 KB |
Output is correct |
29 |
Correct |
13 ms |
2876 KB |
Output is correct |
30 |
Correct |
13 ms |
2872 KB |
Output is correct |
31 |
Correct |
14 ms |
2772 KB |
Output is correct |
32 |
Correct |
19 ms |
2848 KB |
Output is correct |
33 |
Correct |
14 ms |
2832 KB |
Output is correct |
34 |
Correct |
16 ms |
2872 KB |
Output is correct |
35 |
Correct |
13 ms |
2880 KB |
Output is correct |
36 |
Correct |
13 ms |
2892 KB |
Output is correct |
37 |
Correct |
13 ms |
2844 KB |
Output is correct |
38 |
Correct |
14 ms |
2772 KB |
Output is correct |
39 |
Correct |
13 ms |
2800 KB |
Output is correct |
40 |
Correct |
14 ms |
2868 KB |
Output is correct |
41 |
Correct |
13 ms |
2876 KB |
Output is correct |
42 |
Correct |
17 ms |
2872 KB |
Output is correct |
43 |
Correct |
14 ms |
2900 KB |
Output is correct |
44 |
Correct |
17 ms |
2772 KB |
Output is correct |
45 |
Correct |
13 ms |
2872 KB |
Output is correct |
46 |
Correct |
13 ms |
2752 KB |
Output is correct |
47 |
Correct |
14 ms |
2796 KB |
Output is correct |
48 |
Correct |
13 ms |
2776 KB |
Output is correct |
49 |
Correct |
13 ms |
2768 KB |
Output is correct |
50 |
Correct |
14 ms |
2872 KB |
Output is correct |
51 |
Correct |
13 ms |
2880 KB |
Output is correct |
52 |
Correct |
15 ms |
2772 KB |
Output is correct |
53 |
Correct |
13 ms |
2772 KB |
Output is correct |
54 |
Correct |
16 ms |
2980 KB |
Output is correct |
55 |
Correct |
19 ms |
2904 KB |
Output is correct |
56 |
Correct |
19 ms |
3028 KB |
Output is correct |
57 |
Correct |
18 ms |
2880 KB |
Output is correct |
58 |
Correct |
17 ms |
2976 KB |
Output is correct |
59 |
Correct |
15 ms |
2956 KB |
Output is correct |
60 |
Correct |
15 ms |
3028 KB |
Output is correct |
61 |
Correct |
14 ms |
2900 KB |
Output is correct |
62 |
Correct |
15 ms |
2980 KB |
Output is correct |
63 |
Correct |
15 ms |
3028 KB |
Output is correct |
64 |
Correct |
15 ms |
3028 KB |
Output is correct |
65 |
Correct |
15 ms |
2952 KB |
Output is correct |
66 |
Correct |
14 ms |
3028 KB |
Output is correct |
67 |
Correct |
14 ms |
3048 KB |
Output is correct |
68 |
Correct |
15 ms |
3028 KB |
Output is correct |
69 |
Correct |
22 ms |
3028 KB |
Output is correct |
70 |
Correct |
20 ms |
3028 KB |
Output is correct |
71 |
Correct |
15 ms |
2900 KB |
Output is correct |
72 |
Correct |
15 ms |
2900 KB |
Output is correct |
73 |
Correct |
15 ms |
3028 KB |
Output is correct |
74 |
Correct |
15 ms |
2936 KB |
Output is correct |
75 |
Correct |
15 ms |
3064 KB |
Output is correct |
76 |
Correct |
15 ms |
3028 KB |
Output is correct |
77 |
Correct |
14 ms |
3008 KB |
Output is correct |
78 |
Correct |
14 ms |
3028 KB |
Output is correct |
79 |
Correct |
16 ms |
2988 KB |
Output is correct |
80 |
Correct |
16 ms |
3000 KB |
Output is correct |
81 |
Correct |
16 ms |
3156 KB |
Output is correct |
82 |
Correct |
15 ms |
3052 KB |
Output is correct |
83 |
Correct |
14 ms |
2880 KB |
Output is correct |
84 |
Correct |
14 ms |
2876 KB |
Output is correct |
85 |
Correct |
14 ms |
2876 KB |
Output is correct |
86 |
Correct |
15 ms |
2968 KB |
Output is correct |
87 |
Correct |
14 ms |
2960 KB |
Output is correct |
88 |
Correct |
14 ms |
2892 KB |
Output is correct |
89 |
Correct |
14 ms |
3028 KB |
Output is correct |
90 |
Correct |
15 ms |
3004 KB |
Output is correct |
91 |
Correct |
14 ms |
2900 KB |
Output is correct |
92 |
Correct |
15 ms |
2880 KB |
Output is correct |
93 |
Correct |
13 ms |
2944 KB |
Output is correct |
94 |
Correct |
14 ms |
2876 KB |
Output is correct |
95 |
Correct |
15 ms |
2868 KB |
Output is correct |
96 |
Correct |
14 ms |
2772 KB |
Output is correct |
97 |
Correct |
14 ms |
2772 KB |
Output is correct |
98 |
Correct |
16 ms |
3000 KB |
Output is correct |
99 |
Correct |
14 ms |
2804 KB |
Output is correct |
100 |
Correct |
16 ms |
3008 KB |
Output is correct |
101 |
Correct |
15 ms |
3008 KB |
Output is correct |
102 |
Correct |
16 ms |
2988 KB |
Output is correct |
103 |
Correct |
13 ms |
2860 KB |
Output is correct |
104 |
Correct |
442 ms |
34160 KB |
Output is correct |
105 |
Correct |
14 ms |
2808 KB |
Output is correct |
106 |
Correct |
458 ms |
34332 KB |
Output is correct |
107 |
Correct |
339 ms |
19940 KB |
Output is correct |
108 |
Correct |
347 ms |
30920 KB |
Output is correct |
109 |
Correct |
308 ms |
23796 KB |
Output is correct |
110 |
Correct |
288 ms |
23512 KB |
Output is correct |
111 |
Correct |
363 ms |
27168 KB |
Output is correct |
112 |
Correct |
14 ms |
2884 KB |
Output is correct |
113 |
Correct |
13 ms |
2772 KB |
Output is correct |
114 |
Correct |
331 ms |
39760 KB |
Output is correct |
115 |
Correct |
456 ms |
45052 KB |
Output is correct |
116 |
Correct |
276 ms |
38124 KB |
Output is correct |
117 |
Correct |
324 ms |
39788 KB |
Output is correct |
118 |
Correct |
465 ms |
44964 KB |
Output is correct |
119 |
Correct |
330 ms |
39744 KB |
Output is correct |
120 |
Correct |
463 ms |
44948 KB |
Output is correct |
121 |
Correct |
453 ms |
44972 KB |
Output is correct |
122 |
Correct |
447 ms |
44844 KB |
Output is correct |
123 |
Correct |
289 ms |
39824 KB |
Output is correct |
124 |
Correct |
464 ms |
44928 KB |
Output is correct |
125 |
Correct |
447 ms |
44940 KB |
Output is correct |
126 |
Correct |
479 ms |
44864 KB |
Output is correct |
127 |
Correct |
467 ms |
44872 KB |
Output is correct |
128 |
Correct |
305 ms |
39868 KB |
Output is correct |
129 |
Correct |
471 ms |
44872 KB |
Output is correct |
130 |
Correct |
441 ms |
44944 KB |
Output is correct |
131 |
Correct |
448 ms |
44908 KB |
Output is correct |
132 |
Correct |
458 ms |
44848 KB |
Output is correct |
133 |
Correct |
454 ms |
44924 KB |
Output is correct |
134 |
Correct |
272 ms |
39872 KB |
Output is correct |
135 |
Correct |
476 ms |
45028 KB |
Output is correct |
136 |
Correct |
296 ms |
38140 KB |
Output is correct |
137 |
Correct |
338 ms |
39956 KB |
Output is correct |
138 |
Correct |
284 ms |
39892 KB |
Output is correct |
139 |
Correct |
279 ms |
38108 KB |
Output is correct |
140 |
Correct |
326 ms |
39728 KB |
Output is correct |
141 |
Correct |
286 ms |
39816 KB |
Output is correct |
142 |
Correct |
466 ms |
44992 KB |
Output is correct |
143 |
Correct |
304 ms |
39796 KB |
Output is correct |
144 |
Correct |
303 ms |
38096 KB |
Output is correct |
145 |
Correct |
475 ms |
44900 KB |
Output is correct |
146 |
Correct |
435 ms |
44872 KB |
Output is correct |
147 |
Correct |
461 ms |
44956 KB |
Output is correct |
148 |
Correct |
495 ms |
44964 KB |
Output is correct |
149 |
Correct |
391 ms |
34044 KB |
Output is correct |
150 |
Correct |
474 ms |
34280 KB |
Output is correct |
151 |
Correct |
359 ms |
19940 KB |
Output is correct |
152 |
Correct |
352 ms |
31052 KB |
Output is correct |
153 |
Correct |
336 ms |
23792 KB |
Output is correct |
154 |
Correct |
287 ms |
23492 KB |
Output is correct |
155 |
Correct |
340 ms |
23776 KB |
Output is correct |
156 |
Correct |
13 ms |
2868 KB |
Output is correct |
157 |
Correct |
12 ms |
2772 KB |
Output is correct |
158 |
Correct |
280 ms |
38064 KB |
Output is correct |
159 |
Correct |
15 ms |
2860 KB |
Output is correct |
160 |
Correct |
515 ms |
45052 KB |
Output is correct |
161 |
Correct |
303 ms |
39904 KB |
Output is correct |
162 |
Correct |
275 ms |
39932 KB |
Output is correct |
163 |
Correct |
290 ms |
39904 KB |
Output is correct |