import sequtils,strutils,math,algorithm var N = stdin.readline.parseInt A = stdin.readline.split.map(parseInt) hp = 100 maxhp = 100 flag : array[16, bool] cnt : int A.sort(system.cmp) var flag2 = true while cnt < N and flag2: flag2 = false for i,a in A: if flag[i] == false and hp + a > 0: if a > 0: hp = min(hp + a, maxhp) else: hp += a maxhp += 100 cnt += 1 flag[i] = true flag2 = true break if cnt == N: echo hp else: echo 0