David's Magic Array


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 512M

Author:
Problem type

David is the proud collector of arrays but no longer has space for one of them. Whilst inspecting the array he's decided to say goodbye to he discovers it's magic gasp.

  • Every second, David can add an arbitrary (possibly negative) integer to every non-zero element in the array.
  • When all elements are zero, the array explodes; problem solved.

David is an incredibly busy student so he would like to explode this array as fast as possible. Compute the minimum time in which we can explode the array.

Input Specification

Two lines. The first contains an integer \(n(1\leq n \leq 10^5)\)

The second line contains \(n\) integers \(x_1, x_2,...,x_n(-10^4 \leq x_i \leq 10^4)\) - David's magic array.

Output Specification

A single integer - the minimum number of seconds David needs to explode the array.

Sample Input 1

7
1 1 1 2 2 2 2

Sample Output 1

2

Sample Input 2

4
2 0 1 4

Sample Output 2

3

Comments

There are no comments at the moment.