IX Olimpiada Informatyczna 2001/2002

Task: izo

Author: Zbigniew Czech

II stage contest 
The company Insumax produces multilayer thermal insulators. Each of the i layers, i=1, 2, ..., n, of such an insulator is characterized by positive insulation coefficient a_{i}. The layers are numbered according to the direction the heat leaks.
heat >  a_{1}  a_{2}  ...  a_{i}  a_{i+1}  ...  a_{n}  >
The insulation coefficient of the whole insulator, A, is described by the sum of insulation coefficients of its layers. Moreover, the coefficient A raises if a layer with a smaller insulation coefficient is followed by a layer with a larger coefficient, according to the formula:
For example, the insulation coefficient of the insulator of the form
>  5  4  1  7  >
is A = (5+4+1+7)+(71) = 23.
4 5 4 1 7the correct answer is in the following output file izo.out:
24