#C3162. Minimum Moves to Target

    ID: 46559 Type: Default 1000ms 256MiB

Minimum Moves to Target

Minimum Moves to Target

You are given an array of integers and a target value. In one move, you can change any array element so that it becomes equal to the target value. Your task is to determine the minimum number of moves required to make every element in the array equal to the given target.

Note: If the array is empty, no moves are needed.

The formula for the number of moves is given by:

[ \text{moves} = \sum_{i=1}^{n} \mathbf{1}_{{a_i \neq \text{target}}} ]

where \( a_i \) are the elements of the array and \( \mathbf{1}_{\{a_i \neq \text{target}\}} \) is 1 if \( a_i \) is not equal to the target, otherwise 0.

inputFormat

The input is given through standard input (stdin) in the following format:

  1. The first line contains a single integer \( n \) representing the number of elements in the array.
  2. If \( n > 0 \), the second line contains \( n \) integers separated by spaces representing the elements of the array. If \( n = 0 \), the array is empty and the second line is omitted.
  3. The last line contains a single integer representing the target value.

outputFormat

Output a single integer to standard output (stdout) which is the minimum number of moves required to convert every element of the array to the target value.

## sample
3
1 2 3
2
2

</p>