# Here your code !

N = gets.to_i
as=[]
ops=[]
gets.split.each_with_index{|v,i|
    if i==0
        as[0]=v.to_i
    else
        j=(i-1)/2+1
        if i%2==1
            ops[j]=v
        else
            as[j]=v.to_i
        end
    end
}
total = as[0]
i=1
mode='+'
while i < N
   #  puts "i=#{i}, total=#{total}"
    if mode == '+'
        if ops[i]=='+'
            total += as[i]
        else
            total -= as[i]
            mode = '-'
        end
    else
        if ops[i]=='-'
            total += as[i]
        else
            j=i
            pval=0
            while ops[j]=='+' && j<N
                pval += as[i]
                j+=1
            end
            if ops[j]=='-' && as[j]>pval
                total += as[j] - pval
                i = j
            else
                total += as[i]
                mode = '+'
            end
        end
    end
    i+=1
end
puts total
