Problem

Submissions

Solution

New

Discuss

3

Difficulty: EASY

Avg. time to solve

27 min

Problem Statement

Suggest Edit

```
1. If 'x' == 'y', both stones are totally destroyed;
2. If 'x' != 'y', the stone of weight 'x' is totally destroyed, and the stone of weight 'y' has a new weight equal to 'y - x'.
```

```
The first line of input contains the integer 'N', representing the total number of stones.
The second line of input contains 'N' single space-separated integers, representing the weights of the stones.
```

```
The only output line prints the weight of the last stone, if it exists, 0 otherwise.
```

```
You do not need to print anything; it has already been taken care of. Just implement the given functions.
```

```
1 <= N <= 10^5
1 <= W <= 10^6
Time Limit: 1 sec
```

```
1
10
```

```
10
```

```
There is Only one stone so the weight of the last stone is 10
```

```
3
1 9 5
```

```
3
```

Console