In this problem, your task is to use ASCII graphics to paint a cardiogram. 

A cardiogram is a polyline with the following corners:$(0 ; 0),(a_{1} ; a_{1}),(a_{1} + a_{2} ; a_{1} - a_{2}),(a_{1} + a_{2} + a_{3} ; a_{1} - a_{2} + a_{3}), \ldots,(\sum_{i = 1}^{n} a_{i} ; \sum_{i = 1}^{n}(- 1)^{i + 1} a_{i})$

That is, a cardiogram is fully defined by a sequence of positive integers a_1, a_2, ..., a_{n}.

Your task is to paint a cardiogram by given sequence a_{i}.


-----Input-----

The first line contains integer n (2 ≤ n ≤ 1000). The next line contains the sequence of integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 1000). It is guaranteed that the sum of all a_{i} doesn't exceed 1000.


-----Output-----

Print max |y_{i} - y_{j}| lines (where y_{k} is the y coordinate of the k-th point of the polyline), in each line print $\sum_{i = 1}^{n} a_{i}$ characters. Each character must equal either « / » (slash), « \ » (backslash), « » (space). The printed image must be the image of the given polyline. Please study the test samples for better understanding of how to print a cardiogram.

Note that in this problem the checker checks your answer taking spaces into consideration. Do not print any extra characters. Remember that the wrong answer to the first pretest doesn't give you a penalty.


-----Examples-----
Input
5
3 1 2 5 1

Output
      / \     
   / \ /   \    
  /       \   
 /         \  
          \ / 

Input
3
1 5 1

Output
 / \     
  \    
   \   
    \  
     \ /

Difficulty: MEDIUM_HARD
Tags: Implementation

Starter code:

Solutions:
n = int(input())
a = [int(i) for i in input().split()]
miny = 0
maxy = 0
s = 0
for i in range(n):
	if i % 2 == 0:
		s += a[i]
	else:
		s -= a[i]
	maxy = max(s, maxy)
	miny = min(s, miny)
dif = maxy - miny
size = sum(a)
res = [[' '] * size for i in range(dif)]
cur = [maxy, 0]
for i in range(n):
	if i % 2 == 0:
		cur[0] -= 1
	else:
		cur[0] += 1
	for j in range(a[i]):
		if i % 2 == 0:
			res[cur[0]][cur[1]] = '/'
			cur[0] -= 1
		else:
			res[cur[0]][cur[1]] = '\\'
			cur[0] += 1
		cur[1] += 1
for i in res:
	print(''.join(i))


n = int(input())
a = list(map(int, input().split()))
x = [0] * (n + 1)
y = [0] * (n + 1)
for i in range(1, n + 1):
	x[i] = x[i - 1] + a[i - 1]
	y[i] = y[i - 1]
	if i % 2 == 0:
		y[i] -= a[i - 1]
	else:
		y[i] += a[i - 1]
m = min(y)
if m < 0:
	for i in range(n + 1):
		y[i] -= m
w = max(x)
h = max(y)
d = [[' '] * w for i in range(h)]
for i in range(n):
	if y[i] < y[i + 1]:
		for j in range(a[i]):
			d[y[i] + j][x[i] + j] = '/'
	else:
		for j in range(a[i]):
			d[y[i] - j - 1][x[i] + j] = '\\'
print('\n'.join((''.join(d[i]) for i in reversed(range(h)))))


import operator
n = int(input())
a = tuple(map(int, str.split(input())))
p = [(0, 0)]
for (i, x) in enumerate(a):
	p.append((p[-1][0] + x, p[-1][1] + (-1) ** i * x))
ymax = max(p, key=operator.itemgetter(1))[1]
ymin = min(p, key=operator.itemgetter(1))[1]
columns = []
for i in range(n):
	(x1, y1) = p[i]
	(x2, y2) = p[i + 1]
	while x1 != x2:
		if y1 < y2:
			columns.append(' ' * (ymax - y1 - 1) + '/' + ' ' * (y1 - ymin))
			y1 += 1
		else:
			columns.append(' ' * (ymax - y1) + '\\' + ' ' * (y1 - ymin - 1))
			y1 -= 1
		x1 += 1
print(str.join('\n', [str.join('', t) for t in zip(*columns)]))


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
n = r()
a = rl()
w = sum(a)
h = -math.inf
d = math.inf
ptr = 0
for (i, j) in enumerate(a):
	ptr += j - 1 if i % 2 == 0 else 1 - j
	h = max(h, ptr)
	d = min(d, ptr)
b = [[' '] * w for i in range(h + abs(d) + 1)]
j = 0
incr = True
for i in range(n):
	H = a[i]
	while H != 0:
		if incr:
			b[h][j] = '/'
			j += 1
			h -= 1
		else:
			b[h][j] = '\\'
			j += 1
			h += 1
		H -= 1
	if incr:
		h += 1
	else:
		h -= 1
	incr = not incr
for i in b:
	print(*i, sep='')


n = int(input())
a = list(map(int, input().split()))
graph = [[' '] * 1000 for _ in range(2001)]
(x, y) = (0, 1000)
for i in range(n):
	for j in range(a[i]):
		if i % 2:
			graph[y][x] = '\\'
			if j != a[i] - 1:
				y += 1
		else:
			graph[y][x] = '/'
			if j != a[i] - 1:
				y -= 1
		x += 1
for i in range(2000, -1, -1):
	graph[i] = ''.join(graph[i][:x])
	if not len(set(graph[i]) & set(['/', '\\'])):
		graph.pop(i)
print('\n'.join(graph))


n = int(input())
a = [int(c) for c in input().split()]
kardio = [[]]

def add_to_kardio(index, symbol):
	for i in range(len(kardio)):
		tmp = symbol if i == index else ' '
		kardio[i].append(tmp)

def add_empty_top(length):
	kardio.insert(0, [' '] * length)

def add_empty_bottom(length):
	kardio.append([' '] * length)
current_x = 0
current_y = -1
for i in range(len(a)):
	if i % 2 == 0:
		current_y += 1
		for t in range(a[i]):
			current_y -= 1
			if current_y >= 0:
				add_to_kardio(current_y, '/')
			else:
				add_empty_top(current_x)
				current_y = 0
				add_to_kardio(current_y, '/')
			current_x += 1
	else:
		current_y -= 1
		for t in range(a[i]):
			current_y += 1
			if current_y < len(kardio):
				add_to_kardio(current_y, '\\')
			else:
				add_empty_bottom(current_x)
				add_to_kardio(current_y, '\\')
			current_x += 1
for i in range(len(kardio)):
	print(''.join(kardio[i]))


import sys
import math
n = int(sys.stdin.readline())
movement_array = [int(nbr) for nbr in sys.stdin.readline().split()]
relative_pos = [(0, 1)]
currentPos = 0
direction = 1
for move in movement_array:
	currentPos += move * direction
	direction *= -1
	relative_pos.append((currentPos, direction))
objective_pos = []
minimum = min(relative_pos, key=lambda x: x[0])[0]
for n in range(0, len(relative_pos)):
	objective_pos.append((relative_pos[n][0] + -minimum, relative_pos[n][1]))
width = 0
for n in range(0, len(objective_pos) - 1):
	width += math.fabs(objective_pos[n + 1][0] - objective_pos[n][0])
width = int(width)
height = max(objective_pos, key=lambda x: x[0])[0] + 1
matrix = [[' ' for x in range(width)] for x in range(height - 1)]
xpos = 0
for n in range(0, len(objective_pos) - 1):
	direction = objective_pos[n][1]
	ypos = objective_pos[n][0]
	targetpos = objective_pos[n + 1][0]
	while math.fabs(ypos - targetpos) > 0:
		if direction == 1:
			matrix[ypos][xpos] = '/'
			ypos += 1
		else:
			matrix[ypos - 1][xpos] = '\\'
			ypos -= 1
		xpos += 1
for row in reversed(matrix):
	print(''.join(row))


n = int(input())
a_list = list(map(int, list(str(input()).split(' '))))
out = [' ' * sum(a_list)] * 2000
(cur, pref_size) = (1000, 0)
(cur_max, cur_min) = (1000, 1000)
for k in range(n):
	for i in range(a_list[k]):
		ind = pref_size + i
		if k % 2 == 0:
			out[cur] = out[cur][:ind] + '/' + out[cur][ind + 1:]
			cur += 1
		else:
			out[cur] = out[cur][:ind] + '\\' + out[cur][ind + 1:]
			cur -= 1
	if k % 2 == 1:
		cur += 1
		cur_min = min(cur_min, cur)
	else:
		cur -= 1
		cur_max = max(cur_max, cur)
	pref_size += a_list[k]
for i in range(cur_max, cur_min - 1, -1):
	print(out[i])


n = int(input())
a = list(map(int, input().split()))
(mx, mn) = (1000, 1000)
ans = [[' '] * 2020 for i in range(2020)]
(x, y) = (1000, 0)
for i in range(n):
	if i % 2 == 0:
		for j in range(a[i]):
			ans[x][y] = '/'
			x -= 1
			y += 1
		x += 1
	else:
		for j in range(a[i]):
			ans[x][y] = '\\'
			x += 1
			y += 1
		x -= 1
	mx = max(mx, x)
	mn = min(mn, x)
for i in range(mn, mx + 1):
	print(''.join(ans[i][:y]))


n = int(input())
a = list(map(int, input().split()))
Max = 1000
Min = 1000
sum = 0
for i in range(len(a)):
	sum += a[i]
myMap = [[' '] * 2020 for i in range(2020)]
(x, y) = (1000, 0)
for i in range(n):
	if i & 1 == 0:
		for j in range(a[i]):
			myMap[x][y] = '/'
			x -= 1
			y += 1
		x += 1
	else:
		for j in range(a[i]):
			myMap[x][y] = '\\'
			x += 1
			y += 1
		x -= 1
	Max = max(Max, x)
	Min = min(Min, x)
for i in range(Min, Max + 1):
	print(''.join(myMap[i][:y]))


n = input()
a = list(map(int, input().split()))
l = sum(a)
h = maxh = minh = 1000
table = [[' '] * l for i in range(2001)]
k = 0
sign = 1
for i in a:
	if sign == 1:
		for j in range(i):
			table[h + j][k + j] = '/'
		maxh = max(maxh, h + (i - 1))
		h += i - 1
	else:
		for j in range(i):
			table[h - j][k + j] = '\\'
		minh = min(minh, h - (i - 1))
		h -= i - 1
	k += i
	sign *= -1
for i in range(maxh, minh - 1, -1):
	print(''.join(table[i]))


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
n = mint()
y = 0
x = 0
a = []
t = 0
mx = dict()
my = 10 ** 9
for i in mints():
	for j in range(i):
		if t == 0:
			a.append((x, y, '/'))
			mx[y] = max(mx.get(y, -1), x)
			my = min(my, y)
			y -= 1
		else:
			y += 1
			a.append((x, y, '\\'))
			mx[y] = max(mx.get(y, -1), x)
			my = min(my, y)
		x += 1
	t ^= 1
i = 0
b = []
while my + i in mx:
	b.append([' '] * (mx[my + i] + 1))
	i += 1
for i in a:
	b[i[1] - my][i[0]] = i[2]
for i in b:
	print(*i + [' '] * (x - len(i)), sep='')


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(sys.stdin.readline())

def In():
	return map(int, sys.stdin.readline().split())

def Sn():
	return sys.stdin.readline().strip()

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		(su, mx, t) = (0, 0, 0)
		for i in range(n):
			su += l[i]
			if i & 1:
				t -= l[i]
			else:
				t += l[i]
			mx = max(l[i], mx, abs(t))
		ans = [[' ' for i in range(su)] for j in range(2 * (mx + 1))]
		st_y = mx
		st_x = 0
		for i in range(n):
			for j in range(l[i]):
				if i % 2 == 0:
					ans[st_y][st_x] = '/'
					if j != l[i] - 1:
						st_y -= 1
					st_x += 1
				else:
					ans[st_y][st_x] = '\\'
					if j != l[i] - 1:
						st_y += 1
					st_x += 1
		for x in ans:
			if x.count('\\') + x.count('/'):
				print(''.join(x))
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


import operator
n = int(input())
points = list(map(int, input().split()))

def praf(g):
	for i in g[1:]:
		print(''.join(i))

def calc(n):
	global points
	a = b = 0
	step = 1
	for i in range(n):
		a += points[i]
		b += points[i] * step
		step = -step
	return (a, b)
seq = [(0, 0)]
for i in range(len(points)):
	seq.append(calc(i + 1))
seq = sorted(seq, key=lambda x: x[0])
seq = {i: seq[i] for i in range(len(seq))}
for i in range(len(seq)):
	r = 0
	if i != len(seq) - 1:
		if seq[i][1] > seq[i + 1][1]:
			r = -1
		else:
			r = 1
	seq[i] = seq[i] + tuple([r])
seqy = sorted(seq.items(), key=lambda x: x[1][1], reverse=True)
pts = {x[0]: x[2] for x in seq.values()}
pts[seq[len(seq) - 1][0]] = 1
graph = [[' '] * seq[len(seq) - 1][0] for x in range(seqy[0][1][1] - seqy[-1][1][1] + 1)]
y = seqy[0][1][1]
way = pts[0]
for i in range(len(graph[0])):
	if i in pts.keys():
		if pts[i] != way:
			if way == 1:
				y += 1
			else:
				y -= 1
		way = pts[i]
	graph[y][i] = '/' if way == 1 else '\\'
	y -= way
praf(graph)


n = int(input())
l = list(map(int, input().split()))
mx = 0
mn = 0
s = 0
sm = 0
a = [0] * (n + 1)
for i in range(n):
	sm += l[i]
	if i % 2 == 0:
		s += l[i]
	else:
		s -= l[i]
	mx = max(mx, s)
	mn = min(mn, s)
	a[i + 1] = s
for i in range(n + 1):
	a[i] -= mn
mat = []
for i in range(mx - mn):
	ll = [' '] * sm
	mat.append(ll)
j = a[0]
k = 0
a.append(5)
f = 0
for i in range(n):
	for g in range(l[i]):
		if i % 2 == 0:
			if f == 1:
				j += 1
				f = 0
			mat[j][k] = '/'
			k += 1
			j += 1
			if j >= a[i + 1]:
				j -= 1
		else:
			mat[j][k] = '\\'
			k += 1
			j -= 1
			f = 1
i = len(mat) - 1
while i >= 0:
	for j in mat[i]:
		print(j, end='')
	print()
	i -= 1


n = int(input())
a = list(map(int, input().split()))
x = sum(a)
arr = [[-1, 0, 0]]
for i in range(n):
	if i % 2 == 0:
		arr.append([arr[-1][0] + 1, arr[-1][1], '/'])
		for k in range(a[i] - 1):
			arr.append([arr[-1][0] + 1, arr[-1][1] + 1, '/'])
	else:
		arr.append([arr[-1][0] + 1, arr[-1][1], '\\'])
		for k in range(a[i] - 1):
			arr.append([arr[-1][0] + 1, arr[-1][1] - 1, '\\'])
for i in range(len(arr)):
	(arr[i][0], arr[i][1]) = (arr[i][1], -arr[i][0])
arr.pop(0)
arr.sort()
arr = arr[::-1]
for i in range(len(arr)):
	arr[i][1] = -arr[i][1]
print(' ' * arr[0][1], end='')
print(arr[0][2], end='')
for i in range(1, len(arr)):
	if arr[i][0] == arr[i - 1][0]:
		print(' ' * (arr[i][1] - arr[i - 1][1] - 1), end='')
		print(arr[i][2], end='')
	else:
		print(' ' * (x - arr[i - 1][1] - 1))
		print(' ' * arr[i][1], end='')
		print(arr[i][2], end='')
print(' ' * (x - arr[-1][1] - 1), end='')


(n, a) = (int(input()), list(map(int, input().split())))
if n & 1:
	a.append(0)
(x, t) = (0, [[' '] * sum(a) for i in range(2001)])
y = u = v = 1000
for i in range(0, n, 2):
	for j in range(a[i]):
		t[y][x] = '/'
		x += 1
		y += 1
	v = max(v, y)
	for j in range(a[i + 1]):
		y -= 1
		t[y][x] = '\\'
		x += 1
	u = min(u, y)
for i in range(v - 1, u - 1, -1):
	print(''.join(t[i]))


N = int(2000.0 + 3)
n = int(input())
a = list(map(int, input().split()))
(maxi, mini) = (N // 2, N // 2)
res = [[' '] * N for i in range(N)]
(x, y) = (N // 2, 0)
for i in range(n):
	if i % 2 == 0:
		for j in range(a[i]):
			res[x][y] = '/'
			x -= 1
			y += 1
		x += 1
	else:
		for j in range(a[i]):
			res[x][y] = '\\'
			x += 1
			y += 1
		x -= 1
	maxi = max(maxi, x)
	mini = min(mini, x)
for i in range(mini, maxi + 1):
	print(''.join(res[i][:y]))


n = int(input())
lis = list(map(int, input().split()))
ma = r = 0
mi = a = 0
for i in range(n):
	if i % 2 == 0:
		a += lis[i]
	else:
		a -= lis[i]
	ma = max(ma, a)
	mi = min(mi, a)
	r += lis[i]
mat = [[' '] * r for i in range(ma + abs(mi) + 2)]
ro = ma
col = 0
for i in range(n):
	if i % 2 == 0:
		ro -= 1
		for k in range(lis[i]):
			mat[ro][col] = '/'
			ro -= 1
			col += 1
	else:
		ro += 1
		for k in range(lis[i]):
			mat[ro][col] = '\\'
			ro += 1
			col += 1
for i in mat[:]:
	print(*i, sep='')