Skip to content
UPEEC

Resistors in Series or Parallel

Easy#engineering#electronics· solved by 0 · time limit 2.0 s

Series resistors add: R=R1+R2+…R = R_1 + R_2 + \dots. Parallel resistors add as reciprocals: 1R=1R1+1R2+…\frac1R = \frac1{R_1} + \frac1{R_2} + \dots. Print the total resistance with 2 decimals.

Input

Line 1: series or parallel. Line 2: nn followed by nn resistances in ohms.

Output

The total resistance.

Constraints

1≤n≤10001 \le n \le 1000, each RiR_i between 1 and 10610^6 Ω.

Sample 1

Input

series
3 100 220 330

Output

650.00

Sample 2

Input

parallel
2 1000 1000

Output

500.00

Sign in or join free to run and submit your solution.