package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, tall, short, ti, si, e uint8
	short = 101
	fmt.Fscanf(in, "%d\n", &n)
	for i:=uint8(0); i < n; i++{
		fmt.Fscanf(in, "%d", &e)
		if tall < e{
			tall = e
			ti = i
		}
		if short >= e{
			short = e
			si = i
		}
	}

	if ti == si{
		fmt.Println("0")
	}else if ti < si{
		fmt.Println(ti + n - si - 1)
	}else if ti > si{
		fmt.Println(n - si + ti - 2)
	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	min := 1000
	max := 0
	var minIdx, maxIdx int
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		if a[i] <= min {
			min = a[i]
			minIdx = i
		}
		if a[i] > max {
			max = a[i]
			maxIdx = i
		}
	}
	if maxIdx > minIdx {
		fmt.Print(maxIdx + n - minIdx - 2)
		return
	}
	fmt.Print(maxIdx + n - minIdx - 1)
}

package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)

    heights := make([]int, n, n)
    for i := 0; i < n; i++ {
        fmt.Scan(&heights[i])
    }

    min_i := 0
    min_v := heights[0]
    max_i := 0
    max_v := heights[0]
    for i := 1; i < len(heights); i++ {
        if heights[i] <= min_v {
            min_v = heights[i]
            min_i = i
        }
        if heights[i] > max_v {
            max_v = heights[i]
            max_i = i
        }
    }

    mov := max_i + (len(heights) - 1 - min_i)
    if max_i > min_i {
        mov -= 1
    }
    fmt.Println(mov)
}

//  URL: http://codeforces.com/problemset/problem/144/A
//  PROBLEM RESTATEMENT
//      Calculate number of swaps needed to make minimum of an array the
//      last element and maximum of an array the first element. Can only swap
//      neighboring elements.
//  APPROACH
//      1) Find the rightmost min index. Find the leftmost max index.
//      2) Sum the distance from min index, max index to the ends of the array.
//         If they cross each other, subtract one from the distance.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func findMinIndex(a []int) int {
	minIndex := 0
	minSoFar := 101
	for i := 0; i < len(a); i++ {
		if a[i] <= minSoFar {
			minSoFar = a[i]
			minIndex = i
		}
	}
	return minIndex
}

func findMaxIndex(a []int) int {
	maxIndex := 0
	maxSoFar := 0
	for i := 0; i < len(a); i++ {
		if a[i] > maxSoFar {
			maxSoFar = a[i]
			maxIndex = i
		}
	}
	return maxIndex
}

func solve(a []int) int {
	maxIndex := findMaxIndex(a)
	minIndex := findMinIndex(a)
	distance := len(a) - minIndex - 1 + maxIndex
	if minIndex < maxIndex {
		distance -= 1
	}
	return distance
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fprintf(writer, "%d\n", solve(a))
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var min, max, current int
	minPos := 0
	maxPos := 0
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &current)
		if (i == 0) {
			min = current
			max = current
			continue
		}
		if (current <= min) {
			min = current
			minPos = i
		}
		if (current > max) {
			max = current
			maxPos = i
		}
	}
	swap := 0
	if (minPos < maxPos) {
		swap = 1
	}
	fmt.Println(maxPos + n - 1 - minPos - swap)
}

package main

import (
	"fmt"
	"strings"
	"bufio"
	"os"
)

func readIntArray(line string) []int {

	numStrings := strings.Split(strings.TrimSpace(string(line)), " ")

	numbers := make([]int, 0)

	for _, v := range numStrings {
		var converted int

		fmt.Sscanf(v, "%d", &converted)
		numbers = append(numbers, converted)
	}

	return numbers
}

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func main() {
	reader := bufio.NewReader(os.Stdin)

	var nSoldiers int
	line, _ := Readln(reader)
	fmt.Sscanf(line,"%d", &nSoldiers)

	line, _ = Readln(reader)
	heights := readIntArray(string(line))

	maxHeight, maxHeightIdx := heights[0], 0
	for i:= 1; i < nSoldiers; i++ {
		if heights[i] > maxHeight {
			maxHeight = heights[i]
			maxHeightIdx = i
		}
	}

	nSeconds := 0
	for i := maxHeightIdx; i > 0; i-- {
		heights[i], heights[i - 1] = heights[i - 1], heights[i]
		nSeconds++
	}

	minHeight, minHeightIdx := heights[len(heights) - 1], len(heights) - 1
	for i:= len(heights) - 1; i >= 0; i-- {
		if heights[i] < minHeight {
			minHeight = heights[i]
			minHeightIdx = i
		}
	}

	nSeconds += len(heights) - minHeightIdx - 1

	fmt.Println(nSeconds)
}

package main

import "fmt"

func main() {
	var a, t, max, min, minPos, maxPos int
	min = 101
	max = 0
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d", &a)
		if a > max {
			maxPos = i
			max = a
		}
		if a <= min {
			minPos = i
			min = a
		}
	}
	if maxPos > minPos {
		fmt.Println(maxPos + t - 2 - minPos)
	} else {
		fmt.Println(maxPos + t - 1 - minPos)
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, time, max, min uint8
	var soldiers [100]uint8
	time, max, min = 0, 0, 100
	max_index, min_index := -1, -1

	fmt.Scan(&n)

	for i := 0; uint8(i) < n; i++ {
		fmt.Scan(&soldiers[i])
		if soldiers[i] > max {
			max = soldiers[i]
			max_index = i
		}
		if soldiers[i] <= min {
			min = soldiers[i]
			min_index = i
		}
	}

	if max_index > min_index {
		time = uint8(max_index) + (n - uint8(min_index) - 1) - 1
	} else {
		time = (uint8(max_index)) + (n - uint8(min_index) - 1)
	}
	fmt.Println(time)
}

package main

import "fmt"

func main() {
    var n,a,i_max,i_min int
    fmt.Scan(&n)
    max, min := 0, 101
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        if max < a { max, i_max = a, i }
        if min >= a { min, i_min = a, i }
    }
    if i_max > i_min { fmt.Println(i_max+(n-i_min-1)-1) } else { fmt.Println(i_max+(n-i_min-1)) }
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

// https://codeforces.com/problemset/problem/144/A
// A. Arrival of the General
// time limit per test
// 2 seconds
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// A Ministry for Defense sent a general to inspect the Super Secret Military Squad under the command of the Colonel SuperDuper. Having learned the news, the colonel ordered to all n squad soldiers to line up on the parade ground.

// By the military charter the soldiers should stand in the order of non-increasing of their height. But as there's virtually no time to do that, the soldiers lined up in the arbitrary order. However, the general is rather short-sighted and he thinks that the soldiers lined up correctly if the first soldier in the line has the maximum height and the last soldier has the minimum height. Please note that the way other solders are positioned does not matter, including the case when there are several soldiers whose height is maximum or minimum. Only the heights of the first and the last soldier are important.

// For example, the general considers the sequence of heights (4, 3, 4, 2, 1, 1) correct and the sequence (4, 3, 1, 2, 2) wrong.

// Within one second the colonel can swap any two neighboring soldiers. Help him count the minimum time needed to form a line-up which the general will consider correct.
// Input

// The first input line contains the only integer n (2 ≤ n ≤ 100) which represents the number of soldiers in the line. The second line contains integers a1, a2, ..., an (1 ≤ ai ≤ 100) the values of the soldiers' heights in the order of soldiers' heights' increasing in the order from the beginning of the line to its end. The numbers are space-separated. Numbers a1, a2, ..., an are not necessarily different.
// Output

// Print the only integer — the minimum number of seconds the colonel will need to form a line-up the general will like.

func main() {
	bufStdin := bufio.NewReader(os.Stdin)

	var n int
	_, _ = fmt.Fscan(bufStdin, &n)

	heights := make([]int, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscan(bufStdin, &heights[i])
	}

	// look for the shortest person that is furthest right
	var shortest int
	shortestIdx := -1
	for i, h := range heights {
		if shortestIdx == -1 || h <= shortest {
			shortest = h
			shortestIdx = i
		}
	}
	nSwapsForShortest := len(heights) - 1 - shortestIdx

	// look for the tallest person that is furthest left
	var tallest int
	tallestIdx := -1
	for i := len(heights) - 1; i >= 0; i-- {
		h := heights[i]
		if tallestIdx == -1 || h >= tallest {
			tallest = h
			tallestIdx = i
		}
	}
	nSwapsForTallest := tallestIdx

	totalSwaps := nSwapsForShortest + nSwapsForTallest

	// when the shortest is initially to the left of the tallest, one of the swaps we do will be common
	// so it will be double counted between nSwapsForShortest and nSwapsForTallest, this us not double count it
	if tallestIdx > shortestIdx {
		totalSwaps--
	}

	fmt.Print(totalSwaps)
}

package main

// https://codeforces.com/problemset/problem/144/A

import "fmt"

func taskSolution(a []int) int {
	maxi, mini := 0, len(a)-1
	for i, ai := range a {
		if ai > a[maxi] {
			maxi = i
		}
		if ai <= a[mini] {
			mini = i
		}
	}
	if maxi < mini {
		return maxi + len(a) - mini - 1
	}
	return maxi + len(a) - mini - 2
}

func main() {
	var n int
	if _, err := fmt.Scan(&n); err != nil {
		panic(err)
	}

	a := []int{}
	for i := 0; i < n; i += 1 {
		var ai int
		if _, err := fmt.Scan(&ai); err != nil {
			panic(err)
		}
		a = append(a, ai)
	}

	fmt.Println(taskSolution(a))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	var n, h int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&n)
	min := 101
	max := 0
	minIdx := 0
	maxIdx := 0
	for i:=0;i<n;i++{
		fmt.Fscan(in,&h)
		if h<=min{
			min = h
			minIdx = i
		}
		if h>max{
			max = h
			maxIdx = i
		}
	}
	if maxIdx>minIdx{
		fmt.Println(maxIdx + n-minIdx-2)
	}else{
		fmt.Println(maxIdx + n-minIdx-1)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	imin, imax := 0, 0
	A := make([]int, n)
	for i := 0; i < len(A); i++ {
		fmt.Scan(&A[i])
		if A[imin] >= A[i] {
			imin = i
		}
		if A[imax] < A[i] {
			imax = i
		}
	}
	time := imax
	time += (len(A) - 1 - imin)
	if imax > imin {
		time--
	}
	if imax == imin {
		panic("impossible")
	}
	fmt.Println(time)
}

package main

import "fmt"

type Pair struct {
    idx, val int
}

func main() {
    var n int
    fmt.Scanln(&n);
    arr := make([]int, n)
    _max, _min := Pair{0, 0}, Pair{0, 100}
    for i:=0; i<n; i++{
        fmt.Scan(&arr[i])
        if _max.val < arr[i] {
            _max.val = arr[i]
            _max.idx = i
        }
        if _min.val >=  arr[i] {
            _min.val = arr[i]
            _min.idx = i
        }
    }
    if _max.idx > _min.idx {
        fmt.Println(_max.idx + n - _min.idx - 2)
    } else {
        fmt.Println(_max.idx + n - _min.idx - 1)
    }
}

package main

import(
    "fmt"
)

func main(){
    var(
        n,ma,mi,maInd,miInd   int
    )
    fmt.Scan(&n)
    arr := make([]int,n)
    for i:=0;i<n;i++{
        fmt.Scan(&arr[i])
    }
    ma,mi,maInd,miInd=arr[0],arr[0],0,0
    for i:=1;i<n;i++{
        if arr[i] > ma{
            ma = arr[i]
            maInd=i
        }
        if arr[i] < mi{
            mi = arr[i]
            miInd=i
        }
        if arr[i]==ma || arr[i]==mi{
            if arr[i]==ma && i<maInd{
                maInd=i
            }
            if arr[i]==mi && i>miInd{
                miInd=i
            }
        }
    }
    if maInd > miInd{
        miInd=(n-1)-miInd
        fmt.Println(maInd+miInd-1)
    }else if miInd>maInd{
        miInd = (n-1)-miInd
        fmt.Println(maInd+miInd)
    }
}

package main

import (
"fmt"
)

func main() {
	var n,i,maxi,mini,pmax,pmin int64
	maxi = 0
	mini = 101
	fmt.Scan(&n)
	var arr = make([]int64,n)
	for i = 0; i < n; i++ {
		fmt.Scan(&arr[i])
		if arr[i] > maxi {
			maxi = arr[i]
			pmax = i
		}
		if arr[i] <= mini {
			mini = arr[i]
			pmin = i
		}
	}
	ans := pmax + (n-pmin-1)
	if pmin < pmax {
		ans--
	}
	fmt.Printf("%d\n",ans)
}

package main

import (
  "fmt"
)

func main() {
  var a int
  fmt.Scan(&a)
  arr := make([]int, a)
  for i := 0; i < a; i++ {
    fmt.Scan(&arr[i])
  }
  max := arr[0]
  idxmax := 0
  min := arr[0]
  idxmin := 0
  for idx,val := range arr {
    if max < val {
      max = val
      idxmax = idx
    }
  }
  c := 0
  temp := 0
  for i := idxmax; i > 0; i-- {
    temp = arr[i-1]
    arr[i-1] = arr[i]
    arr[i] = temp
    c++
  }
  for idx,val := range arr {
    if min >= val {
      min = val
      idxmin = idx
    }
  }
  for i := idxmin; i < len(arr)-1; i++ {
    temp = arr[i+1]
    arr[i+1] = arr[i]
    arr[i] = temp
    c++
  }
  fmt.Print(c)
}

package main

import "fmt"

func main() {
	var n, max, min, maxP, minP, temp int
	fmt.Scanf("%d \n", &n)
	max = 0
	min = 101
	maxP = -1
	minP = -1
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &temp)
		if max < temp {
			max = temp
			maxP = i
		}
		if min >= temp {
			min = temp
			minP = i
		}
	}

	temp = maxP + (n - 1 - minP)
	if maxP > minP {
		temp--
	}
	fmt.Println(temp)
}

package main

import(
	"fmt"
)

func main() {
	n := 0
	fmt.Scanf("%d\n", &n)
	arr := []int{}
	tmp := 0

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		arr = append(arr, tmp)
	}

	min := arr[0]
	minI := 0
	max := arr[len(arr)-1]
	maxI := len(arr)-1

	for i := n-1; i >= 0; i-- {
		if arr[i] > max || (arr[i] == max && i < maxI) {
			max = arr[i]
			maxI = i
		}
	}

	for i := 0; i < n; i++ {
		if arr[i] < min || (arr[i] == min && i > minI) {
			min = arr[i]
			minI = i
		}
	}

	if maxI > minI {
		fmt.Println(n-1-minI + maxI - 1)
	} else {
		fmt.Println(n-1-minI + maxI)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	heights := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&heights[i])
	}

	max, min := -1, 1000000
	i, j := 0, 0
	for k := 0; k < n; k++ {
		if heights[k] > max {
			max = heights[k]
			i = k
		}
		if heights[k] <= min {
			min = heights[k]
			j = k
		}
	}

	if i > j {
		fmt.Print(i + n - j - 2)
	} else {
		fmt.Print(i + n - j - 1)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int
var a []int

func main() {
	fmt.Fscan(reader, &n)
	a = make([]int, n)
	var min, max, minPos, maxPos int
	min = 110
	max = 0
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &a[i])
		if a[i] <= min {
			min = a[i]
			minPos = i
		}
		if a[i] > max {
			max = a[i]
			maxPos = i
		}
	}
	ans := maxPos + n - 1 - minPos
	if maxPos > minPos {
		ans--
	}
	fmt.Println(ans)
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	a := make([]int, n)
	for i := range a {
		a[i] = readi()
	}
	maxi := 0
	maxv := 0
	mini := 0
	minv := 110
	for i := range a {
		if maxv < a[i] {
			maxv = a[i]
			maxi = i
		}
		if a[i] <= minv {
			minv = a[i]
			mini = i
		}
	}

	ans := maxi + n - mini - 1
	if mini < maxi {
		ans--
	}
	println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d\n",&N)
	arr := make([]int,N)
	for i:= 0 ; i < N ; i++{
		fmt.Scanf("%d",&arr[i])
	}
	min := 0
	max := 0
	for i:= 0 ; i < N ; i++{
		if arr[i] <= arr[min]{
			min = i
		}
		if arr[i] > arr[max]{
			max = i
		}
	}
	result := max + (N-1) - min
	if(max > min){
		result -=1
	}
	fmt.Println(result)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	var n, h int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&n)
	min := 101
	max := 0
	minIdx := 0
	maxIdx := 0
	for i:=0;i<n;i++{
		fmt.Fscan(in,&h)
		if h<=min{
			min = h
			minIdx = i
		}else if h>max{
			max = h
			maxIdx = i
		}
	}
	//fmt.Println(maxIdx,minIdx)
	if maxIdx>minIdx{
		fmt.Println(maxIdx + n-minIdx-2)
	}else{
		fmt.Println(maxIdx + n-minIdx-1)
	}
}

package main

import "fmt"

func solve(a int64) int64 {
	ret := (a + 1) / 2
	if a % 2 != 0 {
		ret = -ret
	}
	return ret
}

func main() {
	var a int64
	fmt.Scan(&a)
	fmt.Println(solve(a))
}

package main

import "fmt"

type Pair struct {
    idx, val int
}

func main() {
    var n int
    fmt.Scanln(&n);
    arr := make([]int, n)
    _max, _min := Pair{0, 2}, Pair{0, 100}
    for i:=0; i<n; i++{
        fmt.Scan(&arr[i])
        if _max.val < arr[i] {
            _max.val = arr[i]
            _max.idx = i
        }
        if _min.val >=  arr[i] {
            _min.val = arr[i]
            _min.idx = i
        }
    }
    if _max.idx > _min.idx {
        fmt.Println(_max.idx + n - _min.idx - 2)
    } else {
        fmt.Println(_max.idx + n - _min.idx - 1)
    }
}

package main

import "fmt"

type Pair struct {
    idx, val int
}

func main() {
    var n int
    fmt.Scanln(&n);
    arr := make([]int, n)
    _max, _min := Pair{0, 2}, Pair{0, 100}
    for i:=0; i<n; i++{
        fmt.Scan(&arr[i])
        if _max.val < arr[i] {
            _max.val = arr[i]
            _max.idx = i
        }
        if _min.val >=  arr[i] {
            _min.val = arr[i]
            _min.idx = i
        }
    }
    if _max.idx == 0 && _min.idx == n-1 {
        fmt.Println(0)
    } else if _max.idx > _min.idx {
        fmt.Println(_max.idx + n - _min.idx - 2)
    } else {
        fmt.Println(_max.idx + n - _min.idx - 1)
    }
}

package main

import (
  "fmt"
)

func main() {
  var a int
  fmt.Scan(&a)
  arr := make([]int, a)
  for i := 0; i < a; i++ {
    fmt.Scan(&arr[i])
  }
  max := arr[0]
  idxmax := 0
  min := arr[0]
  idxmin := 0
  for idx,val := range arr {
    if max < val {
      max = val
      idxmax = idx
    }
  }
  c := 0
  temp := 0
  for i := idxmax; i > 0; i-- {
    temp = arr[i-1]
    arr[i-1] = arr[i]
    arr[i] = temp
    c++
  }
  for idx,val := range arr {
    if min > val {
      min = val
      idxmin = idx
    }
  }
  for i := idxmin; i < len(arr)-1; i++ {
    temp = arr[i+1]
    arr[i+1] = arr[i]
    arr[i] = temp
    c++
  }
  fmt.Print(c)
}

package main

import(
	"fmt"
)

func main() {
	n := 0
	fmt.Scanf("%d\n", &n)
	arr := []int{}
	tmp := 0

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		arr = append(arr, tmp)
	}

	min := arr[0]
	minI := 0
	max := arr[len(arr)-1]
	maxI := len(arr)-1

	for i := n-1; i >= 0; i-- {
		if arr[i] > max || (arr[i] == max && i < maxI) {
			max = arr[i]
			maxI = i
		}
	}

	for i := 0; i < n; i++ {
		if arr[i] < min || (arr[i] == min && i > minI) {
			max = arr[i]
			maxI = i
		}
	}

	if maxI > minI {
		fmt.Println(minI +maxI - 1)
	} else {
		fmt.Println(minI + maxI)
	}
}

package main

import(
	"fmt"
)

func main() {
	n := 0
	fmt.Scanf("%d\n", &n)
	fmt.Println(n)
	arr := []int{}
	tmp := 0

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		arr = append(arr, tmp)
	}

	min := arr[0]
	minI := 0
	max := arr[len(arr)-1]
	maxI := len(arr)-1

	for i := n-1; i >= 0; i-- {
		if arr[i] > max || (arr[i] == max && i < maxI) {
			max = arr[i]
			maxI = i
		}
	}

	for i := 0; i < n; i++ {
		if arr[i] < min || (arr[i] == min && i > minI) {
			max = arr[i]
			maxI = i
		}
	}

	if maxI > minI {
		fmt.Println(minI +maxI - 1)
	} else {
		fmt.Println(minI + maxI)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	heights := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&heights[i])
	}

	max, min := -1, 1000000
	i, j := 0, 0
	for k := 0; k < n; k++ {
		if heights[k] > max {
			max = heights[k]
			i = k
		} else if heights[k] <= min {
			min = heights[k]
			j = k
		}
	}

	if i > j {
		fmt.Print(i + n - j - 2)
	} else {
		fmt.Print(i + n - j - 1)
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	heights := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&heights[i])
	}

	max, min := -1, 1000000
	i, j := 0, 0
	for k := 0; k < n; k++ {
		if heights[k] > max {
			max = heights[k]
			i = k
		} else if heights[k] <= min {
			min = heights[i]
			j = k
		}
	}

	if i > j {
		fmt.Print(i + n - j - 2)
	} else {
		fmt.Print(i + n - j)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var n, tall, short, ti, si, e uint8
	short = 101
	fmt.Fscanf(in, "%d\n", &n)
	for i:=uint8(0); i < n; i++{
		fmt.Fscanf(in, "%d", &e)
		if tall < e{
			tall = e
			ti = i
		}
		if short > e{
			short = e
			si = i
		}
	}

	if ti == si{
		fmt.Println("0")
	}else if ti < si{
		fmt.Println(ti + n - si - 1)
	}else if ti > si{
		fmt.Println(n - si + ti - 3)
	}

}

package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d\n",&N)
	arr := make([]int,N)
	for i:= 0 ; i < N ; i++{
		fmt.Scanf("%d ",&arr[i])
	}
	min := 0
	max := 0
	for i:= 0 ; i < N ; i++{
		if arr[i] <= arr[min]{
			min = i
		}
		if arr[i] > arr[max]{
			max = i
		}
	}
	result := max + (N-1) - min
	if(max > min){
		result -=1
	}
	fmt.Println(result)
}

package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d\n",&N)
	arr := make([]int,N)
	for i:= 0 ; i < N ; i++{
		fmt.Scanf("%d\n",&arr[i])
	}
	min := 0
	max := 0
	for i:= 0 ; i < N ; i++{
		if arr[i] <= arr[min]{
			min = i
		}
		if arr[i] > arr[max]{
			max = i
		}
	}
	result := max + (N-1) - min
	if(max > min){
		result -=1
	}
	fmt.Println(result)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var min, max, current int
	minPos := 0
	maxPos := 0
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &current)
		if (i == 0) {
			min = current
			max = current
			continue
		}
		if (current <= min) {
			min = current
			minPos = i
		}
		if (current >= max) {
			max = current
			maxPos = i
		}
	}
	swap := 0
	if (minPos < maxPos) {
		swap = 1
	}
	fmt.Println(maxPos + n - 1 - minPos - swap)
}

package main

import "fmt"

func main() {
    var n,t int
    var a [55]int
    var s string
    fmt.Scan(&n,&t,&s)
    for i, v := range s { a[i] = int(v) }
    for ; t > 0; t-- {
        for i := 1; i < n; i++ {
            if (a[i] == 'G') && (a[i-1] == 'B') {
                a[i], a[i-1] = a[i-1], a[i]
                i++
            }
        }
    }
    for i := 0; i < n; i++ { fmt.Print(string(a[i])) }
    fmt.Println()
}


package main

import (
	"fmt"
)

func main() {
	var n, x, y, ans int
	ans = 0;
	var s string
	fmt.Scan(&n, &x, &y, &s)
	for i:=n-1; i>=n-x; i-- {
		if i==n-1-y {
			if s[i]==byte('0'){
				ans++
			} else {}
		} else{
			if s[i]==byte('1'){
				ans++;
			} else {}
		}
	}
	fmt.Println(ans);
}

package main

import "fmt"

func main () {
	var n, x, y, cnt int
	cnt = 0
	var str string
	fmt.Scan(&n, &x, &y, &str)
	for i := n-1; i > n-x-1; i-- {
		if string(str[i]) != "0" && i != n-y-1 {
			cnt++
		} else if string(str[i]) != "1" && i == n-y-1 {
			cnt++
		}
	}
	fmt.Println(cnt)
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func Sol1237D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	a := make([]int, 3*n+1)
	for i := range a[:n] {
		Fscan(in, &a[i])
	}
	copy(a[n:2*n], a[:n])
	copy(a[2*n:], a[:n])

	type pair struct{ a, i int }
	q := []pair{{a[0], 0}}
	ql, r := 0, 1
	for i := range a[:n] {
		for ; r < 3*n && (ql == len(q) || 2*a[r] >= q[ql].a); r++ {
			for ql < len(q) && q[len(q)-1].a < a[r] {
				q = q[:len(q)-1]
			}
			q = append(q, pair{a[r], r})
		}
		ans := r - i
		if ans > 2*n {
			ans = -1
		}
		Fprint(out, ans, " ")
		if ql < len(q) && q[ql].i == i {
			ql++
		}
	}
}

func main() {
	Sol1237D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1237D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	a := make([]int, n, 3*n)
	for i := range a {
		Fscan(in, &a[i])
	}
	a = append(append(a, a...), a...)

	q := make([]int, 3*n)
	l, r, j := 0, 0, 0
	for i := range a[:n] {
		for ; j < 3*n && (l == r || 2*a[j] >= a[q[l]]); j++ {
			for ; l < r && a[q[r-1]] <= a[j]; r-- {
			}
			q[r] = j
			r++
		}
		ans := j - i
		if ans > 2*n {
			ans = -1
		}
		Fprint(out, ans, " ")
		if l < r && q[l] == i {
			l++
		}
	}
}

func main() { CF1237D(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func Sol1237D(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var n int
	Fscan(in, &n)
	a := make([]int, 3*n)
	for i := range a[:n] {
		Fscan(in, &a[i])
	}
	copy(a[n:2*n], a[:n])
	copy(a[2*n:], a[:n])

	type pair struct{ a, i int }
	q := []pair{{a[0], 0}}
	ql, j := 0, 1
	for i := range a[:n] {
		for ; j < 3*n && (ql == len(q) || 2*a[j] >= q[ql].a); j++ {
			for ql < len(q) && q[len(q)-1].a < a[j] {
				q = q[:len(q)-1]
			}
			q = append(q, pair{a[j], j})
		}
		ans := j - i
		if ans > 2*n {
			ans = -1
		}
		Fprint(out, ans, " ")
		if ql < len(q) && q[ql].i == i {
			ql++
		}
	}
}

func main() {
	Sol1237D(os.Stdin, os.Stdout)
}

package main

import (
	"bufio"
	"container/heap"

	. "fmt"
	"os"
	"strconv"
)

var (
	inn = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func cmax(a *int, b int) {
	if b > *a {
		*a = b
	}
}

type node struct {
	i, x int
}
type pq []node

func (h pq) Len() int {
	return len(h)
}
func (h pq) Less(i, j int) bool {
	if h[i].x == h[j].x {
		return h[i].i > h[j].i
	}
	return h[i].x > h[j].x
}
func (h pq) Swap(i, j int) {
	h[i], h[j] = h[j], h[i]
}
func (h *pq) Push(x interface{}) {
	*h = append(*h, x.(node))
}
func (h *pq) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}
func main() {
	defer out.Flush()
	inn.Buffer([]byte{}, 10000000)
	inn.Split(bufio.ScanWords)
	//prep
	n := rd()
	a := make([]node, 3*n)
	ans := make([]int, 400005)
	for i := 0; i < n; i++ {
		x := rd()
		a[i] = node{i, x}
		a[i+n] = node{i + n, x}
		a[i+2*n] = node{i + 2*n, x}
	}
	mn := 0

	q := &pq{}
	heap.Init(q)

	for i := 0; i < 3*n; i++ {
		heap.Push(q, a[i])
		for 2*a[i].x < (*q)[0].x {
			now := heap.Pop(q)
			for mn <= now.(node).i {
				ans[mn] = i - mn
				mn++
			}
		}
	}
	for i := 0; i < n; i++ {
		if ans[i] > 0 {
			Fprintf(out, "%d ", ans[i])
		} else {
			Fprint(out, "-1 ")
		}
	}

}

//-------------------template------------------
type pair struct {
	first, second int
}

func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func maxll(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func rd() (x int) {
	inn.Scan()
	x, _ = strconv.Atoi(string(inn.Bytes()))
	return x
}
func rdll() (x int64) {
	inn.Scan()
	x, _ = strconv.ParseInt(string(inn.Bytes()), 10, 64)
	return x
}
func rdch() (x byte) {
	inn.Scan()
	return inn.Bytes()[0]
}
func rds() string {
	inn.Scan()
	return string(inn.Bytes())
}


package main
import (
	"fmt"
	//"sort"
	//"unicode/utf8"
)
func main() {
	var n,k int
	fmt.Scan(&n,&k)
	a:=make([]int,31)
	tot:=make([]bool,905)
	t:=1
	for i:=0;i<k;i++ {
		fmt.Scan(&a[i])
		tot[a[i]]=true
	}
	for i:=0;i<k;i++ {
		fmt.Print(a[i]," ")
		for j:=0;j<n-1;t++ {
			if tot[t]==false {
				fmt.Print(t, " ")
				j++
			}
		}
		fmt.Println()
	}
}

package main

import "fmt"

func main() {
    var n,k int
    var a [35]int
    f := make(map[int]bool)
    fmt.Scan(&n,&k)
    for i := 0; i < k; i++ {
        fmt.Scan(&a[i])
        f[a[i]] = true
    }
    in := 1
    for i := 0; i < k; i++ {
        fmt.Print(a[i])
        for j := 1; j < n; j++ {
            for f[in] { in++ }
            fmt.Print(" ",in)
            in++
        }
        fmt.Println()
    }
}

// 244A-mic
package main

import (
    "fmt"
)

func main() {
    var n, k int
    var b [901]int
    fmt.Scan(&n, &k)
    a := make([]int, 1000)
    for i := 1; i <= k; i++ {
        fmt.Scan(&a[i])
        b[a[i]] = 1
    }
    for i := 1; i <= k; i++ {
        fmt.Print(a[i])
        for j := 1; j <= n-1; j++ {
            for l := 1; l <= n*k; l++ {
                if b[l] == 0 {
                    fmt.Print(" ")
                    fmt.Print(l)
                    b[l] = 1
                    break
                }
            }
        }
        fmt.Println()
    }
}


package main

import "fmt"

func main() {
    var t,a int
    fmt.Scan(&t)
    for ; t > 0; t-- {
        fmt.Scan(&a)
        if (360 % (180-a)) == 0 {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

package main

import (
	"bufio"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	scanner.Scan()
	t := toInt(scanner.Bytes())
	for t > 0 {
		scanner.Scan()
		n := toInt(scanner.Bytes())
		if canBePolygon(n) {
			writer.WriteString("YES\n")
		}else {
			writer.WriteString("NO\n")
		}
		t--
	}
}

func canBePolygon(n int) bool {
	if 360 % (180 - n) == 0 {
		return true
	}
	return false
}

func toInt(buf []byte) int {
	var n int
	for _, v := range buf {
		n = n * 10 + int(v - '0')
	}
	return n
}

package main

import (
	"fmt"
)

func main() {
	var n, t int
	fmt.Scanf("%d\n", &n)

	for n > 0 {
		fmt.Scanf("%d\n", &t)
		if check(t) == true {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
		n--
	}
}

func check(t int) bool {
	if 360%(180-t) == 0 {
		return true
	}
	return false
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"strconv"
	"os"
)

func main() {
    defer s.Flush()

	for n := s.Next(); n > 0; n-- {
		if  360 % (180 - s.Next()) == 0 {
			s.Println("YES")
	    } else {
			s.Println("NO")
		}
	}
}

var (
	s *InOut
)

func init() {
	s = NewInOut(os.Stdin, os.Stdout)
}

type InOut struct {
	*bufio.Reader
	*bufio.Writer
}

func NewInOut(r io.Reader, w io.Writer) *InOut {
	return &InOut{bufio.NewReader(r), bufio.NewWriter(w)}
}

// Get Next Integer
func (s *InOut) Next() (r int) {
	b, _ := s.ReadByte()
	p := 1
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

func (s *InOut) NextInt64() (r int64) {
	b, _ := s.ReadByte()
	p := int64(1)
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int64(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

// Get Next Line String
func (s *InOut) NextLine() (r string) {
    b, _ := s.ReadByte()
    for b == '\r' || b == '\n' {
        b, _ = s.ReadByte()
    }
    buf := make([]byte, 0)
    for ; b != '\r' && b != '\n'; b, _ = s.ReadByte() {
        buf = append(buf, b)
    }
    return string(buf)
}

// Get Next String using delimiter whitespace
func (s *InOut) NextStr() (r string) {
    return string(s.NextBytes())
}

// Get Next String using delimiter whitespace
func (s *InOut) NextBytes() (r []byte) {
	b, _ := s.ReadByte()
	for b == '\n' || b == ' ' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n' && b != ' '; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return buf
}

// Print Strings using the suitable way to change type
func (s *InOut) Print(os ...interface{}) {
	for _, o := range os {
		switch o.(type) {
		case byte:
			s.WriteByte(o.(byte))
		case string:
			s.WriteString(o.(string))
		case int:
			s.WriteString(strconv.Itoa(o.(int)))
		case int64:
			s.WriteString(strconv.FormatInt(o.(int64), 10))
		default:
			s.WriteString(fmt.Sprint(o))
		}
	}
}

// Print Strings using the suitable way to change type with new line
func (s *InOut) Println(os ...interface{}) {
	for _, o := range os {
		s.Print(o)
	}
	s.Print("\n")
}

// Print immediately with new line (for debug)
func (s *InOut) PrintlnNow(o interface{}) {
	fmt.Println(o)
}

package main
import (
	"fmt"
)
func main() {
	var d, a int
	fmt.Scan(&d)
	for i:=0;i<d;i++ {
		fmt.Scan(&a)
		if (360%(180-a))==0 {
			fmt.Println("YES")
		} else { fmt.Println("NO")}
	}
}

package main

import (
	"fmt"
)

func test(x int) bool {
	return x > 0 && x < 180 && 360%(180-x) == 0 && 360/(180-x) >= 3
}

func main() {
	var n, temp int
	fmt.Scanf("%d \n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d \n", &temp)
		if test(temp) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var t int
	fmt.Scan(&t)

	v := 0
	for i := 0; i < t; i++ {
		fmt.Scan(&v)
		if 360%(180-v) != 0 {
			fmt.Println("NO")
		} else {
			n := 360 / (180 - v)
			if n < 3 {
				fmt.Println("NO")
			} else {
				fmt.Println("YES")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var inf int = 0x3f3f3f3f
var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var t, a int

func main() {
	fmt.Fscan(reader, &t)
	for ; t != 0; t-- {
		fmt.Fscan(reader, &a)
		n := 180 * 2 / (180 - a)
		if n*(180-a) == 180*2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
    "fmt"
    )

func can_build(angle int) bool {
    for i := 3; angle * i >= 180 * (i-2); i++ {
        if angle * i == 180 * (i-2) {
            return true
        }
    }

    return false
}

func main() {
    var t int
    fmt.Scan(&t)

    for i := 0; i < t; i++ {
        var angle int
        fmt.Scan(&angle)
        if can_build(angle) {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

// 270A-mic
package main

import (
	"fmt"
)

func main() {
	var n, k int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&k)
		if 360%(180-k) == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main
import (
    "fmt"
)
func main() {
    var d, a int
    fmt.Scan(&d)
    for i:=0;i<d;i++ {//1 + 2n
        fmt.Scan(&a)
        if (360%(180-a))==0 {
            fmt.Println("YES")
        } else { fmt.Println("NO")}
    }
}

package main

import "fmt"

func main() {
	var a, angle int
	fmt.Scan(&a)
	for i := 0; i < a; i++ {
		fmt.Scan(&angle)
		if (360 % (180 - angle)) == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var count int
	var angle int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscanln(reader, &count)
	for i := 0; i < count; i++ {
		fmt.Fscanln(reader, &angle)
		if 360%(180-angle) == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math/rand"
	"os"
)

const INF  = 1000000001

type Pair struct {
	first, second int
}

func sort(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func solution(reader io.Reader, writer io.Writer) {
	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var a int
		fmt.Fscanf(reader, "%d\n", &a)
		if 360 % (180 - a) == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}

package main

import "fmt"

var mp map[int]bool

func init() {
	mp = make(map[int]bool)
	for i := 3; i <= 180; i++ {
		if 180%i == 0 {
			mp[180/i*(i-2)] = true
		}
	}
}

func main() {
	var t, x int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&x)
		/*
			if mp[x] {
				fmt.Println("YES")
			} else {
				fmt.Println("NO")
			}
		*/
		if x >= 60 && 360%(180-x) == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	t := 0
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		n := 0
		fmt.Scanf("%d\n", &n)
		if n < 60 {
			fmt.Printf("NO\n")
		} else {
			if status(n) == false {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		}
		t = t - 1
	}
}

func status(x int) bool {
	var n float32
	n = 180 - float32(x)
	n = float32(360) / n
	var t int = int(n)
	var t2 = float32(t)
	if t2 == n {
		return true
	}
	return false
}

package main

import (
	"fmt"
	"math"
)

func main() {
	t := 0
	fmt.Scanf("%d\n", &t)
	for t > 0 {
		n := 0
		fmt.Scanf("%d\n", &n)
		if n < 60 {
			fmt.Printf("NO\n")
		} else {
			if status(n) == false {
				fmt.Printf("NO\n")
			} else {
				fmt.Printf("YES\n")
			}
		}
		t = t - 1
	}
}

func status(x int) bool {
	n := 180 - x
	n = int(math.Abs(float64(n)))
	if 360%n == 0 {
		return true
	}
	return false
}

package main

import "fmt"
import "math"

func okAngle(a float64) bool {
	n := 360 / (180 - a)
	if n < 3.0 {
		return false
	}
	return n == math.Round(n)
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var a int
		fmt.Scan(&a)
		if okAngle(float64(a)) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var count int
	var angle int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscanln(reader, &count)
	for i := 0; i < count; i++ {
		fmt.Fscanln(reader, &angle)
		if angle >= 60 && 360%angle == 0 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

var mp map[int]bool

func init() {
	mp = make(map[int]bool)
	for i := 3; i <= 180; i++ {
		if 180%i == 0 {
			mp[180/i*(i-2)] = true
		}
	}
}

func main() {
	var t, x int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&x)
		if mp[x] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"strconv"
	"strings"
)

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		for _, i := range arr {
			map_[int(math.Abs(float64(i)))] += 1
		}
		ans := 0.0

		for k, _ := range map_ {
			if k == 0 {
				ans += math.Min(1, float64(map_[k]))
			} else {
				ans += math.Min(2, float64(map_[k]))
			}
		}
		write(int(ans), "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			if mapper[abs(list[j])] >= 1 {
				mapper[abs(list[j])]++
				continue
			}
			mapper[abs(list[j])]= 1
		}
		count:=0
		for i,j := range mapper{
			if j == 1 || i==0 {
				count++
				continue
			}
			count+=2
		}
		fmt.Fprintln(out,count)
	}
}

func abs(x int) int {
	if x < 0 {
		return x*-1
	}
	return x
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func process(r *bufio.Reader) {
	_ = readInt(r)
	mp := make(map[int]int, 0)
	ans := 0
	nums := readLineNumbs(r)
	for _, n := range nums {
		x, _ := strconv.Atoi(n)
		nInt := int(x)
		_, e := mp[nInt]
		if e {
			mp[nInt]++
		} else {
			mp[nInt] = 1
		}
	}
	// debug(mp)
	for k, v := range mp {
		if k > 0 {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		} else {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		}
	}
	fmt.Println(ans)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for i := 0; i < t; i++ {
		process(reader)
	}
}

// Thanks to user: gealbermorales for the valuable guidance with processing input using Go
// Functions are published at https://codeforces.com/blog/entry/94245

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func debug(a interface{}) {
	fmt.Printf("value is = %v \n", a)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		n := readInt(reader)
		a := readArrayInt(reader)
		cnt := make([]int, 101)
		max := 0

		for i := 0; i < n; i++ {
			if a[i] < 0 {
				a[i] *= -1
			}

			cnt[a[i]]++
			if cnt[a[i]] <= 2 && cnt[a[i]] > 0 && a[i] != 0 {
				max++
			}

			if a[i] == 0 && cnt[a[i]] == 1 {
				max++
			}
		}

		fmt.Fprintln(writer, max)

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)

	for test := parseInt(getString(reader)); test > 0; test-- {
		_ = parseInt(getString(reader))
		A := getIntln(reader)
		occurence := make([]uint8, 101)
		for _, v := range A {
			occurence[v]++
		}
		var res int
		if occurence[0] > 0 {
			res++
		}
		for _, v := range occurence[1:] {
			if v > 1 {
				res += 2
			} else if v > 0 {
				res++
			}
		}
		writer.WriteString(fmt.Sprintln(res))
	}
	writer.Flush()
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []uint8 {
	b := strings.Split(getString(in), " ")
	res := make([]uint8, len(b))
	for k, v := range b {
		x, _ := strconv.ParseInt(v, 10, 8)
		if x < 0 {
			x = -x
		}
		res[k] = uint8(x)
	}
	return res
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)

    min := func(a, b int) int {
        if a < b {
            return a
        }
        return b
    }

    var T int
    fmt.Fscan(in, &T)

    for i := 0; i < T; i++ {
        arr := make([]int, 101)
        var n int
        fmt.Fscan(in, &n)

        for j := 0; j < n; j++ {
            var v int
            fmt.Fscan(in, &v)
            if v < 0 {
                arr[v*-1]++
            } else {
                arr[v]++
            }
        }

        var c int
        for idx, v := range arr {
            if idx == 0 {
                c += min(1, v)
            } else {
                c += min(2, v)
            }
        }
        fmt.Fprintln(out, c)
    }
    out.Flush()
}

package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scan(&n)

    for i := 0; i < n; i++ {
        m := make(map[int]int)
        var k int
        fmt.Scan(&k)

        for j := 0; j < k; j++ {
            var n2 int
            fmt.Scan(&n2)
            if n2 != 0 {
                _, ok := m[n2]
                if ok {
                    m[n2*-1] = 1
                } else {
                    m[n2] = 1
                }
            } else {
                m[0] = 1
            }
        }

        fmt.Println(len(m))
    }
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		var n int
		fmt.Fscan(in, &n)
		var a []int = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
			if a[i] < 0 {
				a[i] = -a[i]
			}
		}
		sort.Ints(a)
		var ans = 0
		var zero = false
		for i := 0; i < n; i++ {
			if a[i] == 0 {
				zero = true
				continue
			}
			ans++
			if i > 1 {
				if a[i-1] == a[i] && a[i-2] == a[i] {
					ans--
				}
			}
		}
		if zero {
			ans++
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1616A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1616A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1616A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1616A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1616A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1616A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1616A
Date: 11/01/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1616/A
Problem: CF1616A
**/
func (in *CF1616A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapa := make(map[int]int)
		for i := 0; i < n; i++ {
			val := in.NextInt()
			num, _ := mapa[val]
			mapa[val] = num + 1
		}

		for k, v := range mapa {
			if v > 1 {
				val, _ := mapa[-k]
				mapa[-k] = val + 1
			}
		}

		fmt.Println(len(mapa))
	}
}

func NewCF1616A(r *bufio.Reader) *CF1616A {
	return &CF1616A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1616A(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"fmt"
	"math"
)

func main() {

	t := 0
	fmt.Scan(&t)

	for t > 0 {

		n := 0
		fmt.Scan(&n)
		a := []int{}

		for n > 0 {
			temp := 0
			fmt.Scan(&temp)
			a = append(a, temp)
			n--
		}

		fmt.Println(solve(a))

		t--
	}

	// a := []int{0, 0}
	// fmt.Println(solve(a))
}

func solve(a []int) int {

	record := make([]int, 101)
	count := 0

	for i := range a {
		val := math.Abs(float64(a[i]))
		record[int(val)]++
	}

	for i := range record {

		if i == 0 {
			if record[i] > 0 {
				count++
			}
			continue
		}

		if record[i] == 1 {
			count += 1
		} else if record[i] > 1 {
			count += 2
		}

	}

	return count
}

package main

import "fmt"

var (
	T   int
	n   int
	tax = [105]int{}
)

func min(a int, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func main() {
	fmt.Scanln(&T)
	for T > 0 {
		fmt.Scanln(&n)
		for i := 0; i <= 100; i++ {
			tax[i] = 0
		}
		for i, a := 1, 0; i <= n; i++ {
			fmt.Scan(&a)
			tax[abs(a)]++
		}
		ans := 0
		for i := 0; i <= 100; i++ {
			if i == 0 {
				ans += min(1, tax[i])
			} else {
				ans += min(2, tax[i])
			}
		}
		fmt.Printf("%d\n", ans)
		fmt.Scanln()
		T--
	}
}

package main

import "fmt"

func main() {
	var numTestCases uint

	fmt.Scan(&numTestCases)
	for testCase := numTestCases; testCase > 0; testCase-- {
		var n uint
		fmt.Scan(&n)

		var elm int
		uniqueElements := make(map[int]struct{}, n)
		for i := n; i > 0; i-- {
			fmt.Scan(&elm)
			if _, containsElm := uniqueElements[elm]; !containsElm {
				uniqueElements[elm] = struct{}{}
			} else if _, containsElm := uniqueElements[-elm]; !containsElm {
				uniqueElements[-elm] = struct{}{}
			}
		}

		fmt.Println(len(uniqueElements))
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	err = bufio.NewWriter(os.Stderr)
)

func main() {
	defer out.Flush()
	//redirectInputToFile(in, "input.txt")

	T := readInt()
	for t := 0; t < T; t++ {
		solve()
	}
}

func solve() {
	n := readInt()
	m := make(map[int]int, 0)
	for i := 0; i < n; i++ {
		next := readInt()
		if next == 0 {
			m[next] = 1
			continue
		}
		if next < 0 {
			next = -next
		}
		m[next]++
	}
	var ans int
	for _, v := range m {
		if v >= 2 {
			ans += 2
		} else {
			ans += 1
		}
	}
	println(ans)
}

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// READ
func readInt() int {
	var res int
	fmt.Fscan(in, &res)
	return res
}

func readInt64() int64 {
	var res int64
	fmt.Fscan(in, &res)
	return res
}

func readString() string {
	var res string
	fmt.Fscan(in, &res)
	return res
}

// PRINT
func print(args ...interface{}) {
	fmt.Fprint(out, args...)
	out.Flush()
}

func println(args ...interface{}) {
	fmt.Fprintln(out, args...)
	out.Flush()
}

func printErr(args ...interface{}) {
	fmt.Fprint(err, args...)
	err.Flush()
}

func printlnErr(args ...interface{}) {
	fmt.Fprintln(err, args...)
	err.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	//file, _ := os.Open("input.txt")
	//in := bufio.NewReader(file)
	in := bufio.NewReader(os.Stdin)

	input1 := readArrInt(in)
	t := input1[0]
	for ; t != 0; t-- {
		input := readArrInt(in)
		n := input[0]
		var arr [101]bool
		var arr2 [101]bool
		ans := 0
		inp := readArrInt(in)
		for i := 0; i < n; i++ {
			num := abs(inp[i])
			if arr[num] == false {
				ans++
				arr[num] = true
			} else if num != 0 && arr2[num] == false {
				ans++
				arr2[num] = true
			}
		}
		fmt.Println(ans)
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func readFloat(in *bufio.Reader) float64 {
	nStr := readStr(in)
	n, _ := strconv.ParseFloat(nStr, 64)
	return n
}

func readInt(in *bufio.Reader) int {
	nStr := readStr(in)
	n, _ := strconv.Atoi(nStr)
	return n
}

func readStr(in *bufio.Reader) string {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	return nStr
}

func readLineNumbs(in *bufio.Reader) []string {
	line := readStr(in)
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o, p := map[int]int{}, 0
		for j := 0; j < n; j++ {
			fmt.Fscan(f, &p)
			o[p]++
			if o[p] > 1 {
				o[-p]++
				o[p]--
			}
		}
		fmt.Fprintln(w, len(o))
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"fmt"
)

var mp map[int]int

func main(){

	var tst int
// 	tst1, err1 :=
    fmt.Scan(&tst)
// 	if err1 !=nil {
// 	    fmt.Println(tst1, err1)
// 	}
	for i:=0 ; i< tst; i++ {
		mp = make(map[int]int)
		var n int
		var a int
		cnt :=0
// 		n1, err :=
        fmt.Scan(&n)
// 		if err != nil {
//           fmt.Println(n1,err)
//         }
		for j :=1 ; j<=n; j++{

// 			a1, err2 :=
           fmt.Scan(&a)
		  //  if err2 != nil {
    //               fmt.Println(a1,err2)
    //         }

			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1
			}
		}

		fmt.Printf("%d\n", cnt)
	}
}

package main

import (
// 	"bufio"
	"fmt"
// 	"os"
)

// var reader *bufio.Reader = bufio.NewReader(os.Stdin)
// var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

var mp map[int]int

func main(){
// 	defer writer.Flush()
	var tst int
	tst1, err1 := fmt.Scanf("%d", &tst)
	if err1 !=nil {
	    fmt.Println(tst1, err1)
	}
// 	fmt.Println("tst=",tst)
	for i:=0 ; i< tst; i++ {
		mp = make(map[int]int)
		var n int
		var a int
		cnt :=0
		n1, err := fmt.Scan(&n)
		if err != nil {
           fmt.Println(n1,err)
        }
// 		fmt.Println("val =",n,"\ni=",i)
		for j :=1 ; j<=n; j++{
// 			fmt.Scanf("%d", &a)
			a1, err2 := fmt.Scan(&a)
		    if err2 != nil {
                  fmt.Println(a1,err2)
            }
            // fmt.Println(j ,"=" , a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

			}
// 			fmt.Printf("%d ", cnt)
		}

		fmt.Printf("%d\n", cnt)
	}
}

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			if i == n-1 {
				fmt.Scanf("%d\n", &data[i])
			} else {
				fmt.Scanf("%d", &data[i])
			}
			if data[i] < 0 {
				data[i] = -data[i]
			}
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				ans += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import(
    "fmt"
)

func main(){
  var x int
  fmt.Scan(&x)

  for d := 0; d < x ; d++{
    valuesMap := make(map[int]int)
      var howMany int
      fmt.Scan(&howMany)
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           if _,ok := valuesMap[temp]; ok{
             valuesMap[temp]++
           }else{valuesMap[temp] = 1  }
         }
    unique := 0
    for c,_ := range valuesMap{
      if  _,ok := valuesMap[-c]; ok  && c < 0{
      }else{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
  }
    fmt.Println(unique)
  }

}

package main

import "fmt"

var mp map[int]int

func main(){
	var tst int
	// fmt.Scanln(&tst)
	fmt.Scanf("%d", &tst)
	for i:=0 ; i< tst; i++ {
		mp = make(map[int]int)
		var n,a int
		cnt :=0
		// fmt.Scanln(&n)
		fmt.Scanf("%d", &n)
		for j :=0 ; j<n; j++{
			// fmt.Scanln(&a)
			fmt.Scanf("%d", &a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

			}
		}
		fmt.Printf("%d\n", cnt)
	}
}

package main

import "fmt"

func main(){
	var tst int
	// fmt.Scanln(&tst)
	fmt.Scanf("%d", &tst)
	for i:=0 ; i< tst; i++ {
		mp := make(map[int]int)
		var n,a int
		cnt :=0
		// fmt.Scanln(&n)
		fmt.Scanf("%d", &n)
		for j :=0 ; j<n; j++{
			// fmt.Scanln(&a)
			fmt.Scanf("%d", &a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

			}
		}
		fmt.Println(cnt)
	}
}

package main

import "fmt"

func main(){
	var tst int
	fmt.Scanln(&tst)
	for i:=0 ; i< tst; i++ {
		mp := make(map[int]int)
		var n,a int
		cnt :=0
		fmt.Scanln(&n)
		for j :=0 ; j<n; j++{
			fmt.Scanln(&a)
			if mp[a]==0{
				cnt++
				mp[a]=1
			}else if mp[-a]==0{
				cnt++
				mp[-a]=1

			}
		}
		fmt.Println(cnt)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"strconv"
	"strings"
)

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		for _, i := range arr {
			map_[i] += 1
		}
		ans := 0.0

		for k, _ := range map_ {
			if k == 0 {
				ans += math.Min(1, float64(map_[k]))
			} else {
				ans += math.Min(2, float64(map_[k]))
			}
		}
		write(int(ans), "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"strconv"
	"strings"
)

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		for _, i := range arr {
			map_[i] += 1
		}
		ans := 0.0

		for k, v := range map_ {
			if k == 0 {
				ans += math.Min(1, float64(map_[v]))
			} else {
				ans += math.Min(2, float64(map_[v]))
			}
		}
		write(int(ans), "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"reflect"
	"strconv"
	"strings"
)

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

func main() {
	// START WRITING YOUR SOLUTION HERE:
	// writeLine(typeOf(readInt()))
	t := readInt()

	for t > 0 {
		_ = readInt()
		// 		writeLine(k)
		map_ := make(map[int]int)
		arr := readInts()
		count := 0
		for _, i := range arr {
			i = int(math.Abs(float64(i)))
			if i == 0 && map_[i] == 0 {
				map_[i] += 1
				count += 1
			} else if map_[i] < 3 &&  i!=0 {
				map_[i] += 1
				count += 1
			}
		}
		write(count, "\n")
		t--
	}

}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main
import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

/*
3
4
1 1 2 2
3
1 2 3
2
0 0

*/
func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var t int
	scanf("%d", &t)

	var num int

	for ; t > 0; t -= 1 {
	    var count int
		scanf("%d", &num)
		map_ := make(map[int]int)
		for i := 0; i < num; i += 1 {
			var j int
			scanf("%d", &j)
			if map_[j] <= 2 {
				map_[j] += 1
				count += 1
			}
		}
		printf("%d\n", count)
	}

}

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			if i == n-1 {
				fmt.Scanf("%d\n", &data[i])
			} else {
				fmt.Scanf("%d", &data[i])
			}
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				ans += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &data[i])
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				ans += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import "fmt"

func main() {
	cases := 0
	fmt.Scanf("%d\n", &cases)
	for c := 0; c < cases; c++ {
		n := 0
		fmt.Scanf("%d\n", &n)
		data := make([]int, n)
		memo := make(map[int]int)
		for i := 0; i < n; i++ {
			fmt.Scanf("%d", &data[i])
			memo[data[i]]++
		}
		ans := 0
		for num, cnt := range memo {
			if num == 0 {
				ans++
				continue
			}
			if cnt < 2 {
				ans += cnt
			} else {
				cnt += 2
			}
		}
		fmt.Printf("%d\n", ans)
	}
}

package main

import(
    "fmt"
)

func main(){
  var x int
  fmt.Scan(&x)

  for d := 0; d < x ; d++{
    valuesMap := make(map[int]int)
      var howMany int
      fmt.Scan(&howMany)
      var max,min int
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           if c == 0 { max,min = temp,temp}
           if _,ok := valuesMap[temp]; ok{
             valuesMap[temp]++
           }else{valuesMap[temp] = 1  }
           if temp > max {max = temp}
           if min > temp{min = temp}
         }
    unique := 0
    if max < 0 { max = -min}
    for c:= 0; c <= max ; c++{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
    fmt.Println(unique)
  }

}

package main

import(
    "fmt"
)

func main(){
  var x int
  fmt.Scan(&x)

  for d := 0; d < x ; d++{
    valuesMap := make(map[int]int)
      var howMany int
      fmt.Scan(&howMany)
      var max int
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           if c == 0 { max = temp}
           if _,ok := valuesMap[temp]; ok{
             valuesMap[temp]++
           }else{valuesMap[temp] = 1  }
           if temp > max {max = temp}
         }
    unique := 0
    if max < 0 { max = -max}
    for c:= 0; c <= max ; c++{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
    fmt.Println(unique)
  }

}

package main

import(
    "fmt"
)

func main(){
  var x int
  fmt.Scan(&x)

  for d := 0; d < x ; d++{
    container := make([]int,0)
      var howMany int
      fmt.Scan(&howMany)
         for c := 0; c < howMany; c++{
           var temp int
           fmt.Scan(&temp)
           container = append(container,temp)
         }
    valuesMap := make(map[int]int)
    max := container[0]
    for _,c := range container{
      if _,ok := valuesMap[c]; ok{
        valuesMap[c]++
      }else{valuesMap[c] = 1  }
      if c > max {max = c}
    }
    unique := 0
    for c:= 0; c <= max ; c++{
      if _,ok := valuesMap[c]; ok {
        if c == 0{
          unique++
        }else  if valuesMap[c] >= 2{
          unique +=2
        }else if _,ok := valuesMap[-c]; ok{
              unique +=2
          }else{unique +=1 }
      }else{
        if _,ok := valuesMap[-c]; ok {
          if valuesMap[-c] >= 2{
            unique +=2
        }else{unique +=1 }
      }
      }
    }
    fmt.Println(unique)
  }

}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			if mapper[list[j]] >= 1 {
				mapper[list[j]]++
				continue
			}
			mapper[abs(list[j])]= 1
		}
		count:=0
		for i,j := range mapper{
			if j == 1 || i==0 {
				count++
				continue
			}
			count+=2
		}
		fmt.Fprintln(out,count)
	}
}

func abs(x int) int {
	if x < 0 {
		return x*-1
	}
	return x
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&list[j])
		}
		mapper:= make(map[int]int)
		for j:=0;j<n;j++{
			if mapper[list[j]] >= 1 {
				mapper[list[j]]++
				continue
			}
			mapper[list[j]]= 1
		}
		count:=0
		for i,j := range mapper{
			if j == 1 || i==0 {
				count++
				continue
			}
			count+=2
		}
		fmt.Fprintln(out,count)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func process(r *bufio.Reader) {
	_ = readInt(r)
	mp := make(map[int]int, 0)
	ans := 0
	nums := readLineNumbs(r)
	for _, n := range nums {
		x, _ := strconv.Atoi(n)
		nInt := int(x)
		_, e := mp[nInt]
		if e {
			mp[nInt]++
		} else {
			mp[nInt] = 1
		}
	}
	for k, v := range mp {
		if k > 0 {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		} else {
			ans += 1
		}
	}
	fmt.Println(ans)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for i := 0; i < t; i++ {
		process(reader)
	}
}

// Thanks to user: gealbermorales for the valuable guidance with processing input using Go
// Functions are published at https://codeforces.com/blog/entry/94245

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func debug(a interface{}) {
	fmt.Printf("value is = %v \n", a)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func process() {
	reader := bufio.NewReader(os.Stdin)
	readInt(reader)
	mp := make(map[int]int, 0)
	ans := 0
	nums := readLineNumbs(reader)
	// debug(mp)
	for _, n := range nums {
		x, _ := strconv.Atoi(n)
		nInt := int(x)
		_, e := mp[nInt]
		if e {
			mp[nInt]++
		} else {
			mp[nInt] = 1
		}
	}
	// debug(mp)
	for k, v := range mp {
		if k > 0 {
			if v >= 2 {
				_, e := mp[-k]
				if !e {
					ans += 2
				} else {
					ans += 1
				}
			} else {
				ans += 1
			}
		} else {
			ans += 1
		}
	}
	fmt.Println(ans)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	t := readInt(reader)
	for i := 0; i < t; i++ {
		process()
	}
}

// Thanks to user: gealbermorales for the valuable guidance with processing input using Go
// Functions are published at https://codeforces.com/blog/entry/94245

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func debug(a interface{}) {
	fmt.Printf("value is = %v \n", a)
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		n := readInt(reader)
		s := readString(reader)

		k := 0
		for i := 1; i < n; i++ {
			if s[i] >= s[i-1] {
				k = i
				break
			}
		}

		ans := ""
		for i := 0; i < k; i++ {
			ans += string(s[i])
		}

		for i := k-1; i >=0; i-- {
			ans += string(s[i])
		}

		fmt.Fprintln(writer, ans)

		t--
	}

	writer.Flush()
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		var n int
		fmt.Fscan(in, &n)
		var a []int = make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &a[i])
		}
		sort.Ints(a)
		var ans = 0
		var zero = false
		for i := 0; i < n; i++ {
			if a[i] == 0 {
				zero = true
				continue
			}
			ans++
			if i > 1 {
				if a[i-1] == a[i] && a[i-2] == a[i] {
					ans--
				}
			}
		}
		if zero {
			ans++
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	out.Flush()
}