Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:  for the array $$$[0, 0, 1, 0, 2]$$$ MEX equals to $$$3$$$ because numbers $$$0, 1$$$ and $$$2$$$ are presented in the array and $$$3$$$ is the minimum non-negative integer not presented in the array;  for the array $$$[1, 2, 3, 4]$$$ MEX equals to $$$0$$$ because $$$0$$$ is the minimum non-negative integer not presented in the array;  for the array $$$[0, 1, 4, 3]$$$ MEX equals to $$$2$$$ because $$$2$$$ is the minimum non-negative integer not presented in the array. You are given an empty array $$$a=[]$$$ (in other words, a zero-length array). You are also given a positive integer $$$x$$$.You are also given $$$q$$$ queries. The $$$j$$$-th query consists of one integer $$$y_j$$$ and means that you have to append one element $$$y_j$$$ to the array. The array length increases by $$$1$$$ after a query.In one move, you can choose any index $$$i$$$ and set $$$a_i := a_i + x$$$ or $$$a_i := a_i - x$$$ (i.e. increase or decrease any element of the array by $$$x$$$). The only restriction is that $$$a_i$$$ cannot become negative. Since initially the array is empty, you can perform moves only after the first query.You have to maximize the MEX (minimum excluded) of the array if you can perform any number of such operations (you can even perform the operation multiple times with one element).You have to find the answer after each of $$$q$$$ queries (i.e. the $$$j$$$-th answer corresponds to the array of length $$$j$$$).Operations are discarded before each query. I.e. the array $$$a$$$ after the $$$j$$$-th query equals to $$$[y_1, y_2, \dots, y_j]$$$.

The first line of the input contains two integers $$$q, x$$$ ($$$1 \le q, x \le 4 \cdot 10^5$$$) — the number of queries and the value of $$$x$$$. The next $$$q$$$ lines describe queries. The $$$j$$$-th query consists of one integer $$$y_j$$$ ($$$0 \le y_j \le 10^9$$$) and means that you have to append one element $$$y_j$$$ to the array.

Print the answer to the initial problem after each query — for the query $$$j$$$ print the maximum value of MEX after first $$$j$$$ queries. Note that queries are dependent (the array changes after each query) but operations are independent between queries.

NoteIn the first example:  After the first query, the array is $$$a=[0]$$$: you don't need to perform any operations, maximum possible MEX is $$$1$$$.  After the second query, the array is $$$a=[0, 1]$$$: you don't need to perform any operations, maximum possible MEX is $$$2$$$.  After the third query, the array is $$$a=[0, 1, 2]$$$: you don't need to perform any operations, maximum possible MEX is $$$3$$$.  After the fourth query, the array is $$$a=[0, 1, 2, 2]$$$: you don't need to perform any operations, maximum possible MEX is $$$3$$$ (you can't make it greater with operations).  After the fifth query, the array is $$$a=[0, 1, 2, 2, 0]$$$: you can perform $$$a[4] := a[4] + 3 = 3$$$. The array changes to be $$$a=[0, 1, 2, 2, 3]$$$. Now MEX is maximum possible and equals to $$$4$$$.  After the sixth query, the array is $$$a=[0, 1, 2, 2, 0, 0]$$$: you can perform $$$a[4] := a[4] + 3 = 0 + 3 = 3$$$. The array changes to be $$$a=[0, 1, 2, 2, 3, 0]$$$. Now MEX is maximum possible and equals to $$$4$$$.  After the seventh query, the array is $$$a=[0, 1, 2, 2, 0, 0, 10]$$$. You can perform the following operations:   $$$a[3] := a[3] + 3 = 2 + 3 = 5$$$,  $$$a[4] := a[4] + 3 = 0 + 3 = 3$$$,  $$$a[5] := a[5] + 3 = 0 + 3 = 3$$$,  $$$a[5] := a[5] + 3 = 3 + 3 = 6$$$,  $$$a[6] := a[6] - 3 = 10 - 3 = 7$$$,  $$$a[6] := a[6] - 3 = 7 - 3 = 4$$$.  The resulting array will be $$$a=[0, 1, 2, 5, 3, 6, 4]$$$. Now MEX is maximum possible and equals to $$$7$$$.

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...) }

func main() {
	defer writer.Flush()

	var x, q int

	scanf("%d %d\n", &q, &x)

	occCount := make([]int, x)
	queries := make([]int, q)

	for i := 0; i < q; i++ {
		var y int
		scanf("%d\n", &y)
		y %= x
		queries[i] = y
		occCount[y]++
	}

	minX := 0
	for i := 1; i < x; i++ {
		if occCount[i] < occCount[minX] {
			minX = i
		}
	}
	result := make([]int, q)
	for i := q - 1; i >= 0; i-- {
		result[i] = occCount[minX]*x + minX
		occCount[queries[i]]--
		if occCount[queries[i]] < occCount[minX] || (occCount[queries[i]] == occCount[minX] && queries[i] < minX) {
			minX = queries[i]
		}
	}

	for _, res := range result {
		printf("%d\n", res)
	}

}

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()

	q := readi()
	x := readi()
	m := make([]int, x)
	k := 0
	l := 1
	for i := 0; i < q; i++ {
		y := readi()
		z := y % x
		m[z]++
		for l <= m[k] {
			k = (k + 1) % x
			if k == 0 {
				l++
			}
		}
		println((l-1)*x + k)
	}
}

package main

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

var _ = sort.Slice
var _ = math.Sqrt
var _ = strconv.Itoa

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var q, x, y int
	fmt.Fscan(in, &q, &x)
	var ans []string
	mape := make([]int, x)
	ansi := 0
	for i := 0; i < q; i++ {
		fmt.Fscan(in, &y);
		mape[y%x]++
		for mape[ansi%x] > 0 {
			mape[ansi%x]--
			ansi++
		}
		ans = append(ans, fmt.Sprint(ansi))
	}
	fmt.Fprintln(out, strings.Join(ans, "\n"));
}

// Author: sighduck
// URL: https://codeforces.com/contest/1294/problem/D

package main

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

func Solve(q int, x int, y []int) []int {
	mods := make([]int, x)
	m := 0
	answer := []int{}
	for _, elem := range y {
		mods[elem%x] += 1
		for mods[m%x] > 0 {
			mods[m%x] -= 1
			m += 1
		}
		answer = append(answer, m)
	}
	return answer
}

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

	var q, x int
	fmt.Fscanf(reader, "%d %d\n", &q, &x)
	y := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Fscanf(reader, "%d\n", &y[i])
	}

	answer := Solve(q, x, y)
	for _, elem := range answer {
		fmt.Fprintf(writer, "%d\n", elem)
	}
}

package main

import "fmt"

func main() {
	var x, q int

	_, _ = fmt.Scanf("%d %d", &q, &x)

	occCount := make([]int, x)
	queries := make([]int, q)

	for i := 0; i < q; i++ {
		var y int
		_, _ = fmt.Scanf("%d", &y)
		y %= x
		queries[i] = y
		occCount[y]++
	}

	minX := 0
	for i := 1; i < x; i++ {
		if occCount[i] < occCount[minX] {
			minX = i
		}
	}
	result := make([]int, q)
	for i := q - 1; i >= 0; i-- {
		result[i] = occCount[minX]*x + minX
		occCount[queries[i]]--
		if occCount[queries[i]] < occCount[minX] || (occCount[queries[i]] == occCount[minX] && queries[i] < minX) {
			minX = queries[i]
		}
	}

	for _, res := range result {
		fmt.Println(res)
	}

}


You are given an array of integers $$$b_1, b_2, \ldots, b_n$$$.An array $$$a_1, a_2, \ldots, a_n$$$ of integers is hybrid if for each $$$i$$$ ($$$1 \leq i \leq n$$$) at least one of these conditions is true:   $$$b_i = a_i$$$, or  $$$b_i = \sum_{j=1}^{i} a_j$$$. Find the number of hybrid arrays $$$a_1, a_2, \ldots, a_n$$$. As the result can be very large, you should print the answer modulo $$$10^9 + 7$$$.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$). The second line of each test case contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$-10^9 \le b_i \le 10^9$$$). It is guaranteed that the sum of $$$n$$$ for all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print a single integer: the number of hybrid arrays $$$a_1, a_2, \ldots, a_n$$$ modulo $$$10^9 + 7$$$.

package main

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

/**************

data[i] = read data
acc[i] = acc[i-1] + data[i]
f[i] = sum( f[j] if sum(j, i-1) != 0 ) = sum( f[j] if acc[i-1] - acc[j-1] != 0 )
     = sum( f[j] if acc[i-1] != acc[j-1] )
let k = max{ j, for j in 1..i-2, acc[j-1] = acc[i-1] }
f[k] = sum( f[j] if acc[j-1] != acc[k-1], for j < k ) , as acc[k-1] == acc[j-1]
f[i] = f[k] + f[k+1] + ... + f[i-1]
let accf[i] = accf[i-1] + f[i]
f[i] = accf[i-1] - accf[k-1]

issue: f[0] = ? f[1] = ?

// 1 -1 1

f[0] = 1
data[1] = 1
acc[1] = 1
acc[0] = 0
k = last[acc[1-1]] + 1 = 1 // how to maintain last?
k == i -> f[1] = 0

data[2] = -1
acc[2] = 0
k=last[acc[i-1]] + 1 = last[1] +1 = not found
f[2] =1

data[3] = 1
acc[3] = 1
k=last[acc[i-1]] + 1 = last[0] + 1 = 1
f[3] = f[1] + f[2] = 1

ans = f[0] + f[1] + f[2] + f[3] = 1 + 0 + 1 + 1 = 3

// 0 0 0 1

f[0] = 1
data[1] = 0
acc[1] = 0
acc[0] = 0
k = 1, k== i. f[1] = 0
data[2] = 0
acc[2] = 0
k = last[acc[i-1]] + 1 = last[0] + 1 = 1
f[2] = f[1] = 0
data[3] = 0
acc[3] = 0
k = last[acc[i-1]] + 1 = 2
f[3] = f[2] = 0

data[4] = 1
acc[4] = 1
k = last[acc[i-1]] + 1 = 3
f[4] = f[3] = 0

ans = f[0] + f[1] + f[2] + f[3] + f[4] = 1

// consider last[x] = last occurence of acc[?] = x

****************/

type bigint struct {
	b    [128]byte
	sign int
}

const MODULAR int64 = 1e9 + 7

func main() {
	input := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanln(input, &t)
	for ; t > 0; t-- {
		var n int
		_, err := fmt.Fscanln(input, &n)
		if err != nil {
			panic(err)
		}
		var acc int64
		accf := make([]int64, n+1)
		accf[0] = 1
		last := map[int64]int{0: 0}
		for i := 1; i <= n; i++ {
			var data, f int64
			_, err := fmt.Fscan(input, &data)
			if err != nil {
				panic(err)
			}

			k, found := last[acc]
			last[acc] = i - 1
			k++
			switch {
			case !found:
				f = accf[i-1]
			case k >= i:
			default:
				f = (accf[i-1] - accf[k-1]) % MODULAR
			}
			accf[i] = (accf[i-1] + f) % MODULAR
			acc += data
		}
		fmt.Fscanf(input, "\n")
		ans := accf[n]
		if ans < 0 {
			ans = ans + MODULAR
		}
		fmt.Println(ans)
	}
}

package main

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

const N = 2e5 + 5
const mod = 1e9 + 7

var b [N]int64
var preB [N]int64
var dp [N][2]int

var in = bufio.NewReader(os.Stdin)

func solve(t int) {
	var n int
	fmt.Fscan(in, &n)
	sum := int64(0)
	for i := 1; i <= n; i++ {
		dp[i][0] = 0
		dp[i][1] = 0
		fmt.Fscan(in, &b[i])
		sum += b[i]
		preB[i] = sum
	}
	dp0v := make(map[int64]int)
	dp0vTot := 1
	dp1vTot := 0
	dp0v[0] = 1
	dp[0][0] = 1
	ans := 1
	for i := 1; i < n; i++ {
		ans *= 2
		if ans >= mod {
			ans -= mod
		}
	}
	for i := 1; i < n; i++ {
		dp[i][1] = dp0v[preB[i]] + dp1vTot
		dp[i][1] %= mod
		dp1vTot += dp[i][1]
		dp1vTot %= mod
		dp[i][0] = dp0vTot - dp0v[preB[i]]
		dp[i][0] %= mod
		if dp[i][0] < 0 {
			dp[i][0] += mod
		}
		dp0vTot += dp[i][0]
		if dp0vTot >= mod {
			dp0vTot -= mod
		}
		dp0v[preB[i]] += dp[i][0]
		if dp0v[preB[i]] >= mod {
			dp0v[preB[i]] -= mod
		}
		ans -= dp[i][1]
		if ans < 0 {
			ans += mod
		}
		// fmt.Printf("dp[%d][1]: %d\n", i, dp[i][1])
	}
	fmt.Println(ans)
}

func main() {
	var T int
	fmt.Fscan(in, &T)
	for t := 1; t <= T; t++ {
		solve(t)
	}
}

package main

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

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

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		B := readNNums(reader, n)
		res := solve(n, B)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const MOD = 1000000007

func solve(n int, B []int) int {
	dp := make(map[int64]int64)
	dp[0] = 1
	var tt int64 = 1
	var k int64

	for i := 0; i < n; i++ {
		a := dp[k]
		dp[k] = tt
		k -= int64(B[i])
		tt = (tt*2 + MOD - a) % MOD
	}
	return int(tt)
}

package main

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

/**************

data[i] = read data
acc[i] = acc[i-1] + data[i]
f[i] = sum( f[j] if sum(j, i-1) != 0 ) = sum( f[j] if acc[i-1] - acc[j-1] != 0 )
     = sum( f[j] if acc[i-1] != acc[j-1] )
let k = max{ j, for j in 1..i-2, acc[j-1] = acc[i-1] }
f[k] = sum( f[j] if acc[j-1] != acc[k-1], for j < k ) , as acc[k-1] == acc[j-1]
f[i] = f[k] + f[k+1] + ... + f[i-1]
let accf[i] = accf[i-1] + f[i]
f[i] = accf[i-1] - accf[k-1]

issue: f[0] = ? f[1] = ?

// 1 -1 1

f[0] = 1
data[1] = 1
acc[1] = 1
acc[0] = 0
k = last[acc[1-1]] + 1 = 1 // how to maintain last?
k == i -> f[1] = 0

data[2] = -1
acc[2] = 0
k=last[acc[i-1]] + 1 = last[1] +1 = not found
f[2] =1

data[3] = 1
acc[3] = 1
k=last[acc[i-1]] + 1 = last[0] + 1 = 1
f[3] = f[1] + f[2] = 1

ans = f[0] + f[1] + f[2] + f[3] = 1 + 0 + 1 + 1 = 3

// 0 0 0 1

f[0] = 1
data[1] = 0
acc[1] = 0
acc[0] = 0
k = 1, k== i. f[1] = 0
data[2] = 0
acc[2] = 0
k = last[acc[i-1]] + 1 = last[0] + 1 = 1
f[2] = f[1] = 0
data[3] = 0
acc[3] = 0
k = last[acc[i-1]] + 1 = 2
f[3] = f[2] = 0

data[4] = 1
acc[4] = 1
k = last[acc[i-1]] + 1 = 3
f[4] = f[3] = 0

ans = f[0] + f[1] + f[2] + f[3] + f[4] = 1

// consider last[x] = last occurence of acc[?] = x

****************/

type bigint struct {
	b    [128]byte
	sign int
}

const MODULAR int64 = 1e9 + 7

func main() {
	input := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanln(input, &t)
	for ; t > 0; t-- {
		var n int
		_, err := fmt.Fscanln(input, &n)
		if err != nil {
			panic(err)
		}
		var acc int64
		accf := make([]int64, n+1)
		accf[0] = 1
		last := map[int64]int{0: 0}
		for i := 1; i <= n; i++ {
			var data, f int64
			_, err := fmt.Fscan(input, &data)
			if err != nil {
				panic(err)
			}

			k, found := last[acc]
			last[acc] = i - 1
			k++
			switch {
			case !found:
				f = accf[i-1]
			case k >= i:
			default:
				f = (accf[i-1] - accf[k-1]) % MODULAR
			}
			accf[i] = (accf[i-1] + f) % MODULAR
			acc += data
		}
		fmt.Fscanf(input, "\n")
		fmt.Println(accf[n])
	}
}

package main

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

/**************

data[i] = read data
acc[i] = acc[i-1] + data[i]
f[i] = sum( f[j] if sum(j, i-1) != 0 ) = sum( f[j] if acc[i-1] - acc[j-1] != 0 )
     = sum( f[j] if acc[i-1] != acc[j-1] )
let k = max{ j, for j in 1..i-2, acc[j-1] = acc[i-1] }
f[k] = sum( f[j] if acc[j-1] != acc[k-1], for j < k ) , as acc[k-1] == acc[j-1]
f[i] = f[k] + f[k+1] + ... + f[i-1]
let accf[i] = accf[i-1] + f[i]
f[i] = accf[i-1] - accf[k-1]

issue: f[0] = ? f[1] = ?

// 1 -1 1

f[0] = 1
data[1] = 1
acc[1] = 1
acc[0] = 0
k = last[acc[1-1]] + 1 = 1 // how to maintain last?
k == i -> f[1] = 0

data[2] = -1
acc[2] = 0
k=last[acc[i-1]] + 1 = last[1] +1 = not found
f[2] =1

data[3] = 1
acc[3] = 1
k=last[acc[i-1]] + 1 = last[0] + 1 = 1
f[3] = f[1] + f[2] = 1

ans = f[0] + f[1] + f[2] + f[3] = 1 + 0 + 1 + 1 = 3

// 0 0 0 1

f[0] = 1
data[1] = 0
acc[1] = 0
acc[0] = 0
k = 1, k== i. f[1] = 0
data[2] = 0
acc[2] = 0
k = last[acc[i-1]] + 1 = last[0] + 1 = 1
f[2] = f[1] = 0
data[3] = 0
acc[3] = 0
k = last[acc[i-1]] + 1 = 2
f[3] = f[2] = 0

data[4] = 1
acc[4] = 1
k = last[acc[i-1]] + 1 = 3
f[4] = f[3] = 0

ans = f[0] + f[1] + f[2] + f[3] + f[4] = 1

// consider last[x] = last occurence of acc[?] = x

****************/

type bigint struct {
	b    [128]byte
	sign int
}

const MODULAR int64 = 1e9 + 7

func (b *bigint) set(i *big.Int) {
	i.FillBytes(b.b[:])
	b.sign = i.Sign()
}

func main() {
	input := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanln(input, &t)
	for ; t > 0; t-- {
		var n int
		_, err := fmt.Fscanln(input, &n)
		if err != nil {
			panic(err)
		}
		acc, acb := big.NewInt(0), new(bigint)
		accf := make([]int64, n+1)
		accf[0] = 1
		last := map[bigint]int{*acb: 0}
		for i := 1; i <= n; i++ {
			var data, f int64
			fmt.Fscan(input, &data)

			k, found := last[*acb]
			last[*acb] = i - 1
			k++
			switch {
			case !found:
				f = accf[i-1]
			case k >= i:
			default:
				f = (accf[i-1] - accf[k-1]) % MODULAR
			}
			accf[i] = (accf[i-1] + f) % MODULAR
			acc.Add(acc, big.NewInt(data))
			acb.set(acc)
		}
		fmt.Fscanf(input, "\n")
		fmt.Println(accf[n])
	}
}

package main

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

/**************

data[i] = read data
acc[i] = acc[i-1] + data[i]
f[i] = sum( f[j] if sum(j, i-1) != 0 ) = sum( f[j] if acc[i-1] - acc[j-1] != 0 )
     = sum( f[j] if acc[i-1] != acc[j-1] )
let k = max{ j, for j in 1..i-2, acc[j-1] = acc[i-1] }
f[k] = sum( f[j] if acc[j-1] != acc[k-1], for j < k ) , as acc[k-1] == acc[j-1]
f[i] = f[k] + f[k+1] + ... + f[i-1]
let accf[i] = accf[i-1] + f[i]
f[i] = accf[i-1] - accf[k-1]

issue: f[0] = ? f[1] = ?

// 1 -1 1

f[0] = 1
data[1] = 1
acc[1] = 1
acc[0] = 0
k = last[acc[1-1]] + 1 = 1 // how to maintain last?
k == i -> f[1] = 0

data[2] = -1
acc[2] = 0
k=last[acc[i-1]] + 1 = last[1] +1 = not found
f[2] =1

data[3] = 1
acc[3] = 1
k=last[acc[i-1]] + 1 = last[0] + 1 = 1
f[3] = f[1] + f[2] = 1

ans = f[0] + f[1] + f[2] + f[3] = 1 + 0 + 1 + 1 = 3

// 0 0 0 1

f[0] = 1
data[1] = 0
acc[1] = 0
acc[0] = 0
k = 1, k== i. f[1] = 0
data[2] = 0
acc[2] = 0
k = last[acc[i-1]] + 1 = last[0] + 1 = 1
f[2] = f[1] = 0
data[3] = 0
acc[3] = 0
k = last[acc[i-1]] + 1 = 2
f[3] = f[2] = 0

data[4] = 1
acc[4] = 1
k = last[acc[i-1]] + 1 = 3
f[4] = f[3] = 0

ans = f[0] + f[1] + f[2] + f[3] + f[4] = 1

// consider last[x] = last occurence of acc[?] = x

****************/

type bigint struct {
	b    [128]byte
	sign int
}

const MODULAR int64 = 1e9 + 7

func (b *bigint) set(i *big.Int) {
	i.FillBytes(b.b[:])
	b.sign = i.Sign()
}

func main() {
	input := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanln(input, &t)
	for ; t > 0; t-- {
		var n int
		_, err := fmt.Fscanln(input, &n)
		if err != nil {
			panic(err)
		}
		acc, acb := big.NewInt(0), new(bigint)
		accf := make([]int64, n+1)
		accf[0] = 1
		last := map[bigint]int{*acb: 0}
		for i := 1; i <= n; i++ {
			var data, f int64
			fmt.Fscan(input, &data)

			k, found := last[*acb]
			last[*acb] = i - 1
			k++
			switch {
			case !found:
				f = accf[i-1]
			case k >= i:
			default:
				f = (accf[i-1] - accf[k-1]) % MODULAR
			}
			accf[i] = accf[i-1] + f
			acc.Add(acc, big.NewInt(data))
			acb.set(acc)
		}
		fmt.Fscanf(input, "\n")
		fmt.Println(accf[n])
	}
}


Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of the given n numbers differs from the others. Bob observed that one number usually differs from the others in evenness. Help Bob — to check his answers, he needs a program that among the given n numbers finds one that is different in evenness.

The first line contains integer n (3 ≤ n ≤ 100) — amount of numbers in the task. The second line contains n space-separated natural numbers, not exceeding 100. It is guaranteed, that exactly one of these numbers differs from the others in evenness.

Output index of number that differs from the others in evenness. Numbers are numbered from 1 in the input order.

package main

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

func main() {
	var n, x int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&n)

	ld := make(map[string][]int)

	for i := int(0); i < n; i++ {
		fmt.Fscanf(scr, "%d", &x)

		if x%2 == 0 {
			if ld["even"] == nil {
				ld["even"] = append(ld["even"], 1)
				ld["even"] = append(ld["even"], i)
			} else {
				ld["even"][0]++
				ld["even"][1] = i
			}
		} else {
			if ld["odd"] == nil {
				ld["odd"] = append(ld["odd"], 1)
				ld["odd"] = append(ld["odd"], i)
			} else {
				ld["odd"][0]++
				ld["odd"][1] = i
			}
		}
	}

	if ld["even"][0] < ld["odd"][0] {
		fmt.Println(ld["even"][1] + 1)
	} else {
		fmt.Println(ld["odd"][1] + 1)
	}
}

package main
import "fmt"

func main() {
	var (
		n, num, lastOdd, lastEven, oddNum, evenNum int
	)
	fmt.Scanln(&n)
	for i := 1; i <= n; i ++ {
		fmt.Scanf("%d", &num)
		if num%2 == 1 {
			lastOdd = i
			oddNum ++
		}else {
			lastEven = i
			evenNum ++
		}

		if oddNum > 0 && evenNum > 0 {
			if oddNum > evenNum {
				fmt.Println(lastEven)
				break;
			}

			if evenNum > oddNum {
				fmt.Println(lastOdd)
				break;
			}
		}
	}
}

package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	var lEvenIndex, lOddIndex, evenCount, oddCount, i = -1, -1, 0, 0, 1

	for scanner.Scan() {
		var num = toInt(scanner.Bytes())
		if num % 2 == 0 {
			lEvenIndex = i
			evenCount++
		}else {
			lOddIndex = i
			oddCount++
		}
		i++
	}
	if oddCount == 1 {
		fmt.Println(lOddIndex)
	}else {
		fmt.Println(lEvenIndex)
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var lastEven, lastNotEven, countEven, countNotEven int64
	_, _ = fmt.Scanf("%d\n", &n)
	arr := make([]int64, n, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Scanf("%d", &arr[i])
	}
	for index, element := range arr {
		if element % 2 == 0 {
			lastEven = int64(index)
			countEven++
		} else {
			lastNotEven = int64(index)
			countNotEven++
		}
	}
	if countNotEven == 1 {
		fmt.Printf("%d", lastNotEven + 1)
	} else {
		fmt.Printf("%d", lastEven + 1)
	}
}

/*
%t: для вывода значений типа boolean (true или false)
%b: для вывода целых чисел в двоичной системе
%c: для вывода символов, представленных числовым кодом
%d: для вывода целых чисел в десятичной системе
%o: для вывода целых чисел в восьмеричной системе
%q: для вывода символов в одинарных кавычках
%x: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют нижний регистр a-f
%X: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют верхний регистр A-F
%U: для вывода символов в формате кодов Unicode, например, U+1234
%e: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456e+78
%E: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456E+78
%f: для вывода чисел с плавающей точкой, например, 123.456
%F: то же самое, что и %f
%g: для длинных чисел с плаващей точкой используется %e, для других - %f
%G: для длинных чисел с плаващей точкой используется %E, для других - %F
%s: для вывода строки
%p: для вывода значения указателя - адреса в шестнадцатеричном представлении
*/

package main
import (
	"fmt"
)
func main() {
	var n,x int
	ev,lo,le :=0,0,0
	fmt.Scan(&n)
	for i:=1; i<=n;i++ {
		fmt.Scan(&x)
		if x%2==0 {
			ev++
			le=i
		} else {
			ev--
			lo=i
		}
	}
	if ev>0 {
		fmt.Println(lo)
	} else {
		fmt.Println(le)
	}

}

package main

import "fmt"

func main() {
	var n int
	var x int
	var odds, evens int
	var lastodd, lasteven int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		if x%2 == 0 {
			evens++
			lasteven = i + 1
		} else {
			odds++
			lastodd = i + 1
		}
	}
	if evens > odds {
		fmt.Println(lastodd)
	} else {
		fmt.Println(lasteven)
	}

}

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])
    arr[i] %= 2
  }
  x := 0
  y := 0
  idxx := 0
  idxy := 0
  for idx,val := range arr {
    if val == 1{
      x++
      idxx = idx
    } else {
      y++
      idxy = idx
    }
  }
  if x == 1 {
    fmt.Print(idxx+1)
  }
  if y == 1 {
    fmt.Print(idxy+1)
  }
}

// https://codeforces.com/contest/25/problem/A

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...) }

func main() {
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	var ctOdd, ctEven, idxOdd, idxEven int
	arr := make([]int, n+1)
	for i:=0;i<n;i++ {
		scanf("%d ", &arr[i])
		if arr[i]%2==0 {
			ctEven++
			idxEven = i
		} else {
			ctOdd++
			idxOdd = i
		}
	}

	if ctEven == 1 {
		printf("%d\n", idxEven+1)
	} else {
		printf("%d\n", idxOdd+1)
	}
}

package main

import "fmt"

func main() {
  var n int
  var i int
  var buf int
  var ruf int
  var res int
  fmt.Scanf("%d", &n)
  fmt.Scanln()
  fmt.Scanf("%d", &ruf)
  res = 1
  for i = 0; i < n-1; i++ {
    fmt.Scanf("%d", &buf)
    //fmt.Println("buf----", buf, "----ruf----",ruf, "----i----", i)
    if buf%2 != ruf%2 {res = i+2; break}
  }
  if res==2{
      fmt.Scanf("%d", &ruf)
      if buf%2==ruf%2{
          res=1

      }

  }
  fmt.Println(res)
}

package main

import "fmt"

func main() {
    var n,a,odd,even int
    fmt.Scan(&n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        if a%2 == 0 {
            if even != 0 { even = -1 } else { even = i+1 }
        } else {
            if odd != 0 { odd = -1 } else { odd = i+1 }
        }
    }
    if even == -1 { fmt.Println(odd) } else { fmt.Println(even) }
}

package main

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

var N int
var numbers []uint8

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Scan()
	erhang := scanner.Text()
	// fmt.Println(erhang)
	segs := strings.Split(erhang, " ")
	numbers = make([]uint8, len(segs))
	var shu int
	for idx := range segs {
		shu, _ = strconv.Atoi(segs[idx])
		numbers[idx] = uint8(shu) % 2
	}
	//////////////////////////////////////
	one := numbers[0]
	two := numbers[1]
	var mode bool
	if one == two {
		mode = true
	} else {
		mode = false
	}
	///////////////////////////////////////
	if mode {
		numbers = numbers[2:]
		qian := two
		for idx := range numbers {
			if numbers[idx] != qian {
				fmt.Println(idx + 3)
				return
			}
			qian = numbers[idx]
		}
	} else {
		if numbers[2] == one {
			fmt.Println(2)
		} else {
			fmt.Println(1)
		}
	}
}

package main

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

func checkNumbers(numbers []string, modulo int) int {
	for i := 0; i < len(numbers); i++ {
		tmp, _ := strconv.Atoi(numbers[i])
		if tmp%2 != modulo {
			return i + 1
		}
	}
	//Should not return -1
	return -1
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	n := 0
	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d", &n)
	}

	if scanner.Scan() {
		line := scanner.Text()

		numbers := strings.Fields(line)

		evenCount := 0
		oddCount := 0
		for i := 0; i < 3; i++ {
			tmp, _ := strconv.Atoi(numbers[i])
			if tmp%2 == 0 {
				evenCount += 1
			} else {
				oddCount += 1
			}
		}

		if evenCount > oddCount {
			fmt.Println(checkNumbers(numbers, 0))
		} else {
			fmt.Println(checkNumbers(numbers, 1))
		}
	}
}

package main

import "fmt"

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

	var x int
	var arr []int
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		arr = append(arr, x)
	}

	var evenC, oddC, lastEven, lastOdd int
	for i := 0; i < n; i++ {
		if arr[i]%2 == 0 {
			lastEven = i
			evenC++
		} else {
			lastOdd = i
			oddC++
		}
	}

	if evenC == 1 {
		fmt.Println(lastEven + 1)
	} else {
		fmt.Println(lastOdd + 1)
	}
}

package main

import(
	"fmt"
)

func main() {

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

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

	for i := 0; i < n; i++ {
		if arr[i] % 2 == 0 {
			evenCnt++
		}
	}

	for i := 0; i < n; i++ {
		if evenCnt == n-1 {
			if arr[i] % 2 != 0 {
				fmt.Println(i+1)
				break
			}
		} else {
			if arr[i] % 2 == 0 {
				fmt.Println(i+1)
				break
			}
		}
	}
}

package main

import "fmt"

func main() {
	var inputs int;
	fmt.Scanln(&inputs)

	counterEven := make([]int, 2)
	counterOdd := make([]int, 2)

	for i := 0; i < inputs; i++ {
		var v int;
		fmt.Scanf("%d", &v)

		switch v%2 {
		case 0:
			counterEven[0] = i
			counterEven[1]++
		default:
			counterOdd[0] = i
			counterOdd[1]++
		}
	}

	if counterEven[1] == 1 {
		fmt.Println(counterEven[0] + 1)
	} else {
		fmt.Println(counterOdd[0] + 1)
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	var x [101]int

	fmt.Scanf("%d", &n)
	for i := 0; i < n + 1; i++ {
		fmt.Scanf("%d", &x[i])
	}

	ch :=0
	nch :=0
	for i:=1; i <= n; i++{
		if x[i] % 2 == 0 {
			ch++
			a = i
		}else{
			nch++
			b = i
		}
	}

	if ch > nch{
		fmt.Println(b)
	}else if nch > ch{
		fmt.Println(a)
	}
}

package main

import "fmt"

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

	envInd := 0
	oddInd := 0
	find := 0
	for i := 1; i <= n; i++ {
		fmt.Scan(&v)
		if v%2 == 0 {
			if envInd != 0 {
				find = 1
			} else {
				envInd = i
			}
		} else {
			oddInd = i
		}
	}

	if find == 0 {
		fmt.Print(envInd)
	} else {
		fmt.Print(oddInd)
	}
}

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)
}

func read() (n int) {
	fmt.Fscan(reader, &n)
	return
}

var n int
var a []int

func main() {
	n = read()
	a = make([]int, n)

	var odd, even, oddSum, evenSum int
	for i := 0; i < n; i++ {
		a[i] = read()
		if a[i]%2 == 1 {
			oddSum++
			odd = i + 1
		} else {
			evenSum++
			even = i + 1
		}
	}

	if oddSum == 1 {
		fmt.Println(odd)
	} else {
		fmt.Println(even)
	}
}

package main

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

var DEBUG = true

func main() {
	defer Flush()

	N, A := readInts(0)
	_ = N

	var count, idx [2]int
	for i, v := range A {
		c := v % 2
		count[c]++
		idx[c] = i + 1
	}

	for c := range []int{0, 1} {
		if count[c] == 1 {
			println(idx[c])
		}
	}
}

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

// 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[:len(b):len(b)]
}

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(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...)
}

func dbgf(f string, args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintf(os.Stderr, f, args...)
}

func dbg(args ...interface{}) {
	if !DEBUG {
		return
	}
	fmt.Fprintln(os.Stderr, args...)
}

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

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

// 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 minf(a, b float64) float64 {
	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 maxf(a, b float64) float64 {
	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
}

func absf(a float64) float64 {
	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)
}

package main

import (
	"fmt"
)

func main() {
	var N int
	var iE,iD,sE,sD,temp int
	fmt.Scanf("%d\n",&N)
	for i:=0 ; i<N ; i++{
		fmt.Scanf("%d",&temp)
		if(temp%2 == 0){
			iE = i
			sE += 1
		}else{
			iD = i
			sD += 1
		}
	}
	if(sE < sD){
		fmt.Println(iE+1)
	}else{
		fmt.Println(iD+1)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"sync"
)

func main() {
	n := int(ReadInt64())
	a := ReadInt64Slice(n)

	evn := []int{}
	odd := []int{}

	for i := 0; i < n; i++ {
		if a[i]%2 == 0 {
			evn = append(evn, i)
		} else {
			odd = append(odd, i)
		}
	}
	if len(evn) == 1 {
		fmt.Println(evn[0] + 1)
	} else {
		fmt.Println(odd[0] + 1)
	}
	close(out)
	outWg.Wait()
}

/*********************** I/O ***********************/

var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup

func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	// set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(writer *bufio.Writer) {
		defer outWg.Done()
		defer writer.Flush()

		for line := range out {
			writer.WriteString(line + "\n")
		}
	}(writer)
}

func ReadString() string {
	in.Scan()
	return in.Text()
}

func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}

func ReadInt64() int64 {
	intStr := ReadString()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ReadInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func Max(args ...int64) int64 {
	maxV := int64(math.MinInt64)
	for _, v := range args {
		if v > maxV {
			maxV = v
		}
	}
	return maxV
}

func Min(args ...int64) int64 {
	minV := int64(math.MaxInt64)
	for _, v := range args {
		if v < minV {
			minV = v
		}
	}
	return minV
}

func GCD(a, b int64) int64 {
	if (a == 0) {
		return b
	}
	return GCD(b%a, a)
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

func S(v int64) string {
	return strconv.FormatInt(v, 64)
}

package main

import (
	"fmt"
)

func main() {
	var n, i, e, ei, oi int
	fmt.Scan(&n)
	var arr [100]int
	for i = 0; i < n; i++ {
		fmt.Scan(&arr[i])
		if arr[i]%2 == 0 {
			e++
			ei = i
		} else {
			oi = i
		}
	}
	if e == 1 {
		fmt.Println(ei + 1)
	} else {
		fmt.Println(oi + 1)
	}
}

package main
import (
	"fmt"
)
func main() {
	var n,x int
	ev,lo,le :=0,0,0
	fmt.Scan(&n)
	for i:=1; i<=n;i++ {
		fmt.Scan(&x)
		if x%2==0 {
			ev++
			le=i
		} else {
			ev--
			lo=i
		}
	}
	if ev>0 {
		fmt.Println(lo)
	} else {
		fmt.Println(le)
	}

}

package main

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

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

	// The number of inputs
	var n int
	fmt.Fscanf(in, "%d\n", &n)

	// THe first three inputs
	var a, b, c int
	fmt.Fscanf(in, "%d %d %d", &a, &b, &c)

	sum := 0
	sum = sum<<1 | (a % 2)
	sum = sum<<1 | (b % 2)
	sum = sum<<1 | (c % 2)

	var ind int
	switch sum {
	case 3, 4:
		ind = 1
	case 2, 5:
		ind = 2
	case 1, 6:
		ind = 3
	default:
		ind = -1
	}

	t := 0
	item := 0
	if -1 == ind {
		if 0 == sum {
			item = 1
		} else {
			item = 0
		}

		for i := 3; i < n; i++ {
			fmt.Fscanf(in, " %d", &t)
			if item == (t % 2) {
				ind = i + 1
			}
		}
	} else {
		// Ignore the rest inputs
		for i := 3; i < n; i++ {
			fmt.Fscanf(in, " %d", &t)
		}
	}

	fmt.Fscanf(in, "\n")

	// Display results
	fmt.Fprintf(out, "%d\n", ind)
	out.Flush()
}

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...) }

func main() {
	defer writer.Flush()

	var (
		n       int
		num     int
		even    int
		odd     int
		pos     int
		posEven int
		posOdd  int
	)

	scanf("%d\n", &n)

	for i := 0; i < n; i++ {
		pos++
		scanf("%d", &num)
		if num%2 == 0 {
			even++
			posEven = pos
		} else {
			odd++
			posOdd = pos
		}
	}

	if odd > 1 {
		printf("%d\n", posEven)
	} else {
		printf("%d\n", posOdd)
	}
}

package main

import "fmt"

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

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

    even := 0
    for i := 0; i < 3; i++ {
        if nums[i] % 2 == 0 {
            even += 1
        }
    }

    mod := 0
    if even >= 2 {
        mod = 1
    }

    var ret int
    for i := 0; i < n; i++ {
        if nums[i] % 2 == mod {
            ret = i + 1
            break
        }
    }

    fmt.Println(ret)
}

//  URL: http://codeforces.com/problemset/problem/25/A
//  ~ Basic Implementation Problem

package main

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

func solve(arr []int) int {
	evenCount := 0
	oddCount := 0
	var evenIndex, oddIndex int
	for i, elem := range arr {
		if elem%2 == 0 {
			evenCount += 1
			evenIndex = i + 1
		} else {
			oddCount += 1
			oddIndex = i + 1
		}
	}
	if oddCount >= 2 {
		return evenIndex
	}
	return oddIndex
}

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

package main

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

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

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

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

func main() {

	var T, i uint

	evens := []uint{}
	odds := []uint{}

	scanf("%d \n", &T)
	var temp uint
	for i=1; i<=T; i++ {

		scanf("%d ", &temp)
		if temp % 2 == 0 {
			evens = append(evens, i)
		}else {
			odds = append(odds, i)
		}

	}

	if len(evens) == 1 {
		fmt.Println(evens[0])
	}else {
		fmt.Println(odds[0])
	}

}

package main

import "fmt"

func main() {
	length := 0
	fmt.Scanln(&length)
	numbers := make([]int, length)
	for i := 0; i < length; i++ {
		fmt.Scanf("%d",&numbers[i])
	}
	//fmt.Println(numbers)

	var even,odd,ans1,ans2 int
	for i:=0;i<length;i++{
		if(numbers[i]%2==0){
			even++
			ans1=i+1
		}else {
			odd++
			ans2 =i+1
		}

	}
	if even>odd{
		fmt.Printf("%d",ans2)
	}else{
		fmt.Printf("%d",ans1)
	}

}

package main
import (
	 "fmt"
)

func main() {
	 var n int

	 var odd []int
	 var even []int
	 fmt.Scanf("%d", &n)

	 for i:=1; i<=n; i ++ {
	 	   var x int
	 	   fmt.Scan( &x)

	 	   if x % 2 == 0 {
	 	   		odd = append(odd, i)
	 	   } else {
	 	   	    even = append(even, i)
	 	   }
	 }

	 if len(odd) == 1 {
	 	  fmt.Printf("%d", odd[0])
	 } else {
	 	  fmt.Printf("%d", even[0])
	 }
	 // fmt.Println(odd, even)
}

package main

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

func main() {
	var line string
	var arrS []string
	var tmp, lchet, lnehet, summchet, summnechet int
	var flagchet, flagnechet bool
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	line, _ = reader.ReadString('\n')
	arrS = strings.Split(strings.TrimSpace(line), " ")
	for j := range arrS {
		tmp, _ = strconv.Atoi(arrS[j])
		if tmp%2 == 0 {
			lchet = j + 1
			summchet++
			flagchet = true
		} else {
			lnehet = j + 1
			summnechet++
			flagnechet = true
		}
		if summchet >= 2 && flagnechet {
			fmt.Println(lnehet)
			os.Exit(0)
		}
		if summnechet >= 2 && flagchet {
			fmt.Println(lchet)
			os.Exit(0)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n int
	var idx,idx2,it,it2 int = 0,0,0,0

	fmt.Scan(&n)

	for i := 1; i <= n; i++ {
		var num int
		fmt.Scan(&num)

		if num % 2 == 0 {
			idx++
			it = i
		}else {
			idx2++
			it2 = i
		}
	}

	if idx > idx2 {
		fmt.Println(it2)
	}else{
		fmt.Println(it)
	}
}

package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

func solve(ar []int) int {
        o, e := 0, 0
        for _, v := range ar {
                if v % 2 == 0 {
                        e += 1
                } else {
                        o += 1
                }
        }
        var r int
        if o == 1 {
                r = 1
        } else {
                r = 0
        }
        ans := -1
        for i, v := range ar {
                if v % 2 == r {
                        ans = i+1
                        break
                }
        }

        return ans
}

func main() {
        defer w.Flush()

        var n int
        fmt.Fscanf(r, "%d\n", &n)
        ar := make([]int, n)
        for i := 0; i < n; i++ {
                fmt.Fscanf(r, "%d ", &ar[i])
        }

        fmt.Fprintf(w, "%v", solve(ar))
}

package main

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

func dsuGet(p []int, v int) int {
	if v == p[v] {
		return v
	}
	p[v] = dsuGet(p, p[v])
	return p[v]
}

func dsuUnite(p []int, a, b int) {
	a = dsuGet(p, a)
	b = dsuGet(p, b)
	if rand.Int() & 1 == 1 {
		a, b = b, a
	}
	if a != b {
		p[a] = b
	}
}

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)

	var n int
	fmt.Fscanf(reader, "%d\n", &n)

	var odd, even, oddC, evenC, a int

	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a)
		if a & 1 == 1 {
			odd = i + 1
			oddC++
		} else {
			even = i + 1
			evenC++
		}
	}

	if oddC == 1 {
		fmt.Fprintf(writer, "%d\n", odd)
	} else {
		fmt.Fprintf(writer, "%d\n", even)
	}

	writer.Flush()
}

package main

import "fmt"

func main()  {
	var n, q, w int
	res := true
	q, w = -1, -1
	fmt.Scanf("%d\n", &n)
	for i, tmp := 0, 0; i < n; i++ {
		fmt.Scanf("%d", &tmp)
		if tmp % 2 == 0 {
			if q != -1 {
				res = false
			}
			q = i + 1
		} else {
			if w != -1 {
				res = true
			}
			w = i + 1
		}
	}

	if res {
		fmt.Println(q)
	} else {
		fmt.Println(w)
	}

}

package main

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

import "fmt"

func taskSolution(a []int) int {
	first, second, third := a[0]%2, a[1]%2, a[2]%2
	if !(first == second && second == third) {
		switch {
		case first == second:
			return 3
		case first == third:
			return 2
		default:
			return 1
		}
	}
	for i := 3; i < len(a); i += 1 {
		if a[i]%2 != first {
			return i + 1
		}
	}
	return 0
}

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 "fmt"

func main() {

	var n int
	fmt.Scanln(&n)
	var tem int
	var f0 int = 0 // 上上次
	var f1 int = 0 // 上一个
	var f2 int = 0 // 当前
	var arr [100]int

	for i := 0; i < n; i++ {
		fmt.Scan(&tem)
		arr[i] = tem
	}

	f0 = check(arr[0]) //上上个
	f1 = check(arr[1])
	f2 = check(arr[2])
	if f0 == f1 && f1 == f2 && f2 == f0 {

	} else {
		if f0 == f1 {
			fmt.Println(3)
			return
		}
		if f0 == f2 {
			fmt.Println(2)
			return
		}
		if f1 == f2 {
			fmt.Println(1)
			return
		}
	}
	for i := 3; i < n; i++ {
		f0 = f1
		f1 = f2
		f2 = check(arr[i])
		if f2 != f1 {
			fmt.Println(i + 1)
			return
		}

	}

}

func check(i int) int {

	if i%2 == 0 {
		return 0
	} else {
		return 1
	}

}

package main

import "fmt"

func main() {
	var n, a int
	var fo, fe int
	var ec, oc int
	fe = 0
	fo = 0
	ec = 0
	oc = 0
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a%2 == 0 {
			if ec == 0 {
				fe = i + 1
			}
			ec++
		} else {
			if oc == 0 {
				fo = i + 1
			}
			oc++
		}
	}
	if ec == 1 {
		fmt.Println(fe)
	} else {
		fmt.Println(fo)
	}
}

package main

import (
    "fmt"
)

func main() {
    n := 0;
    fmt.Scanf("%d\n", &n);
    a := make([]int, n);
    for i := 0; i < n; i++ {
        d := 0;
        fmt.Scanf("%d", &d);
        a[i] = d;
    }

    count := 0;
    for i, v := range(a) {
        a[i] = v % 2;
        count += a[i];
    }
    x := 1;

    if (count >= 2) {
        x = 0;
    }

    for i := 0; i < len(a); i++ {
        if a[i] == x {
            fmt.Printf("%d\n", i + 1);
            break;
        }
    }

}

package main

import (
	"fmt"
)

func main() {
	var n int
	var lastEven, lastNotEven, countEven, countNotEven int64
	_, _ = fmt.Scanf("%d", &n)
	arr := make([]int64, n, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Scanf("%d", &arr[i])
	}
	for index, element := range arr {
		if element % 2 == 0 {
			lastEven = int64(index)
			countEven++
		} else {
			lastNotEven = int64(index)
			countNotEven++
		}
	}
	if countNotEven == 1 {
		fmt.Printf("%d", lastNotEven + 1)
	} else {
		fmt.Printf("%d", lastEven + 1)
	}
}

/*
%t: для вывода значений типа boolean (true или false)
%b: для вывода целых чисел в двоичной системе
%c: для вывода символов, представленных числовым кодом
%d: для вывода целых чисел в десятичной системе
%o: для вывода целых чисел в восьмеричной системе
%q: для вывода символов в одинарных кавычках
%x: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют нижний регистр a-f
%X: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют верхний регистр A-F
%U: для вывода символов в формате кодов Unicode, например, U+1234
%e: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456e+78
%E: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456E+78
%f: для вывода чисел с плавающей точкой, например, 123.456
%F: то же самое, что и %f
%g: для длинных чисел с плаващей точкой используется %e, для других - %f
%G: для длинных чисел с плаващей точкой используется %E, для других - %F
%s: для вывода строки
%p: для вывода значения указателя - адреса в шестнадцатеричном представлении
*/

package main

import "fmt"

func main() {
	var n int
	var lastEven, lastNotEven, countEven, countNotEven int64
	_, _ = fmt.Scanf("%d", &n)
	arr := make([]int64, n, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Scanf("%d", &arr[i])
	}
	for index, element := range arr {
		if element % 2 == 0 {
			lastEven = int64(index)
			countEven++
		} else {
			lastNotEven = int64(index)
			countNotEven++
		}
	}
	if countNotEven == 1 {
		fmt.Printf("%d\n", lastNotEven + 1)
	} else {
		fmt.Printf("%d\n", lastEven + 1)
	}
}

/*
%t: для вывода значений типа boolean (true или false)
%b: для вывода целых чисел в двоичной системе
%c: для вывода символов, представленных числовым кодом
%d: для вывода целых чисел в десятичной системе
%o: для вывода целых чисел в восьмеричной системе
%q: для вывода символов в одинарных кавычках
%x: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют нижний регистр a-f
%X: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют верхний регистр A-F
%U: для вывода символов в формате кодов Unicode, например, U+1234
%e: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456e+78
%E: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456E+78
%f: для вывода чисел с плавающей точкой, например, 123.456
%F: то же самое, что и %f
%g: для длинных чисел с плаващей точкой используется %e, для других - %f
%G: для длинных чисел с плаващей точкой используется %E, для других - %F
%s: для вывода строки
%p: для вывода значения указателя - адреса в шестнадцатеричном представлении
*/

package main

import (
	"fmt"
)

func main() {
	var n int
	var lastEven, lastNotEven, countEven, countNotEven int64
	_, _ = fmt.Scanf("%d", &n)
	arr := make([]int64, n, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Scanf("%d", &arr[i])
	}
	for index, element := range arr {
		if element % 2 == 0 {
			lastEven = int64(index)
			countEven++
		} else {
			lastNotEven = int64(index)
			countNotEven++
		}
	}
	if countNotEven == 1 {
		fmt.Printf("%d\n", lastNotEven + 1)
	} else {
		fmt.Printf("%d\n", lastEven + 1)
	}
}

/*
%t: для вывода значений типа boolean (true или false)
%b: для вывода целых чисел в двоичной системе
%c: для вывода символов, представленных числовым кодом
%d: для вывода целых чисел в десятичной системе
%o: для вывода целых чисел в восьмеричной системе
%q: для вывода символов в одинарных кавычках
%x: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют нижний регистр a-f
%X: для вывода целых чисел в шестнадцатиричной системе, буквенные символы числа имеют верхний регистр A-F
%U: для вывода символов в формате кодов Unicode, например, U+1234
%e: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456e+78
%E: для вывода чисел с плавающей точкой в экспоненциальном представлении, например, -1.234456E+78
%f: для вывода чисел с плавающей точкой, например, 123.456
%F: то же самое, что и %f
%g: для длинных чисел с плаващей точкой используется %e, для других - %f
%G: для длинных чисел с плаващей точкой используется %E, для других - %F
%s: для вывода строки
%p: для вывода значения указателя - адреса в шестнадцатеричном представлении
*/

package main

import "fmt"

func main() {
  var n int
  var i int
  var buf int
  var res int
  fmt.Scanf("%d", &n)
  fmt.Scanln()
  fmt.Scanf("%d", &res)
  for i = 0; i < n; i++ {
    fmt.Scanf("%d", &buf)
    if buf%2 != res%2 {res = buf; break}
  }
  fmt.Println(res)
}

package main

import "fmt"

func main() {
  var n int
  var i int
  var buf int
  var ruf int
  var res int
  fmt.Scanf("%d", &n)
  fmt.Scanln()
  fmt.Scanf("%d", &ruf)
  res = 1
  for i = 0; i < n-1; i++ {
    fmt.Scanf("%d", &buf)
    // fmt.Println("buf----", buf, "----ruf----",ruf, "----i----", i)
    if buf%2 != ruf%2 {res = i+2; break}
  }
  fmt.Println(res)
}

package main

import(
	"fmt"
)

func main() {

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

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

	for i := 0; i < n; i++ {
		if ((sum - arr[i]) % (n - 1)) == 0 {
			fmt.Println(i + 1)
		}
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	var x [100]int

	fmt.Scanf("%d", &n)
	for i := 0; i < n+1; i++ {
		fmt.Scanf("%d", &x[i])
	}

	ch := 0
	nch := 0

	for i := 0; i < n; i++ {
		if x[i]%2 == 0 {
			ch++
			a = i
		} else {
			nch++
			b = i
		}
	}

	if ch > nch {
		fmt.Println(b)
	} else {
		fmt.Println(a)
	}

}

package main

import "fmt"

func main() {
	var n, a, b int
	var x [100]int

	fmt.Scanf("%d", &n)
	for i := 1; i < n; i++ {
		fmt.Scanf("%d", &x[i])
	}

	ch :=0
	nch :=0
	for i:= 0; i < n; i++{
		if x[i] % 2 == 0 {
			ch++
			a = i + 1
		}else{
			nch++
			b = i + 1
		}
	}

	if ch > nch{
		fmt.Println(b)
	}else if nch > ch{
		fmt.Println(a)
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	var x [100]int

	fmt.Scanf("%d", &n)
	for i := 1; i <= n; i++ {
		fmt.Scanf("%d", &x[i])
	}

	ch :=0
	nch :=0
	for i:= 0; i < n; i++{
		if x[i] % 2 == 0 {
			ch++
			a = i + 1
		}else{
			nch++
			b = i + 1
		}
	}

	if ch > nch{
		fmt.Println(b)
	}else if nch > ch{
		fmt.Println(a)
	}

}

package main

import "fmt"

func main() {
	var n, a, b int
	var x [100]int

	fmt.Scanf("%d", &n)
	for i := 0; i < n + 1; i++ {
		fmt.Scanf("%d", &x[i])
	}

	ch :=0
	nch :=0

	for i:=0; i < n; i++{
		if x[i] % 2 == 0 {
			ch++
			a = i
		}else{
			nch++
			b = i
		}
	}

	if ch > nch{
		fmt.Println("b = ", b)
	}else{
		fmt.Println("a = ", a)
	}

}

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)
}

func read() (n int) {
	var c byte
	fmt.Fscanf(reader, "%d%c", &n, &c)
	fmt.Println(n, c)
	return
}

var n int
var a []int

func main() {
	n = read()
	a = make([]int, n)

	var odd, even, oddSum, evenSum int
	for i := 0; i < n; i++ {
		a[i] = read()
		if a[i]%2 == 1 {
			oddSum++
			odd = i + 1
		} else {
			evenSum++
			even = i + 1
		}
	}

	if oddSum == 1 {
		fmt.Println(odd)
	} else {
		fmt.Println(even)
	}
}

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)
}

func read() (n int) {
	fmt.Fscan(reader, &n)
	return
}

var n int
var a []int

func main() {
	n = read()
	a = make([]int, n)

	var odd, even, oddSum, evenSum int
	for i := 0; i < n; i++ {
		a[i] = read()
		if a[i]%2 == 1 {
			oddSum++
			odd = i + 1
		} else {
			evenSum++
			even = i + 1
		}
	}

	if oddSum == 1 {
		fmt.Println(odd)
	} else {
		fmt.Println(even)
	}
}

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)
}

func read() (n int) {
	fmt.Fscanf(reader, "%d", &n)
	var c byte
	fmt.Fscanf(reader, "%c", &c)
	return
}

var n int
var a []int

func main() {
	n = read()
	a = make([]int, n)

	var odd, even, oddSum, evenSum int
	for i := 0; i < n; i++ {
		a[i] = read()
		if a[i]%2 == 1 {
			oddSum++
			odd = i + 1
		} else {
			evenSum++
			even = i + 1
		}
	}

	if oddSum == 1 {
		fmt.Println(odd)
	} else {
		fmt.Println(even)
	}
}

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)
}

func read() (n int) {
	var c rune
	fmt.Fscanf(reader, "%d%c", &n, &c)
	return
}

var n int
var a []int

func main() {
	n = read()
	a = make([]int, n)

	var odd, even, oddSum, evenSum int
	for i := 0; i < n; i++ {
		a[i] = read()
		if a[i]%2 == 1 {
			oddSum++
			odd = i + 1
		} else {
			evenSum++
			even = i + 1
		}
	}

	if oddSum == 1 {
		fmt.Println(odd)
	} else {
		fmt.Println(even)
	}
}

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)
}

func read() (n int) {
	var c byte
	fmt.Fscanf(reader, "%d%c", &n, &c)
	return
}

var n int
var a []int

func main() {
	n = read()
	a = make([]int, n)

	var odd, even, oddSum, evenSum int
	for i := 0; i < n; i++ {
		a[i] = read()
		if a[i]%2 == 1 {
			oddSum++
			odd = i + 1
		} else {
			evenSum++
			even = i + 1
		}
	}

	if oddSum == 1 {
		fmt.Println(odd)
	} else {
		fmt.Println(even)
	}
}

package main

import "fmt"

func main() {
	length := 0
	fmt.Scanln(&length)
	numbers := make([]int, length)
	for i := 0; i < length; i++ {
		fmt.Scanf("%d",&numbers[i])
	}
	fmt.Println(numbers)

	var even,odd,ans1,ans2 int
	for i:=0;i<length;i++{
		if(numbers[i]%2==0){
			even++
			ans1=i+1
		}else {
			odd++
			ans2 =i+1
		}

	}
	if even>odd{
		fmt.Printf("%d",ans2)
	}else{
		fmt.Printf("%d",ans1)
	}

}

package main
import (
	 "fmt"
)

func main() {
	 var n int

	 var odd []int
	 var even []int
	 fmt.Scanf("%d", &n)

	 for i:=0; i<n; i ++ {
	 	   var x int
	 	   fmt.Scanf("%d", &x)
	 	   if x % 2 == 0 {
	 	   		odd = append(odd, x)
	 	   } else {
	 	   	    even = append(even, x)
	 	   }
	 }

	 if len(odd) == 1 {
	 	  fmt.Printf("%d", odd[0])
	 } else {
	 	  fmt.Printf("%d", even[0])
	 }
}

package main
import (
	 "fmt"
)

func main() {
	 var n int

	 var odd []int
	 var even []int
	 fmt.Scanf("%d", &n)

	 for i:=0; i<n; i ++ {
	 	   var x int
	 	   fmt.Scanf("%d", &x)

	 	   if x % 2 == 0 {
	 	   		odd = append(odd, i)
	 	   } else {
	 	   	    even = append(even, i)
	 	   }
	 }

	 if len(odd) == 1 {
	 	  fmt.Printf("%d", odd[0])
	 } else {
	 	  fmt.Printf("%d", even[0])
	 }
}

package main

import "fmt"

func main() {
	var t, s1, s2, a int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		if s1 == 2 {
			fmt.Println(i)
		} else if s2 == 2 {
			fmt.Println(i)
		}
		fmt.Scanf("%d ", &a)
		if a%2 == 0 {
			s1++
		} else {
			s2++
		}
	}
}

package main

import "fmt"

func main() {
	var t, s1, s2, a int
	fmt.Scanf("%d\n", &t)
	for i := 0; i <= t; i++ {
		if s1 == 2 {
			fmt.Println(i)
		} else if s2 == 2 {
			fmt.Println(i)
		}
		fmt.Scanf("%d ", &a)
		if a%2 == 0 {
			s1++
		} else {
			s2++
		}
	}
}

package main

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

func main() {
	var line string
	var arrS []string
	var tmp, lchet, lnehet, summchet, summnechet int
	var flagchet, flagnechet bool
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	line, _ = reader.ReadString('\n')
	arrS = strings.Split(strings.TrimSpace(line), " ")
	for j := range arrS {
		tmp, _ = strconv.Atoi(arrS[j])
		if tmp%2 == 0 {
			lchet = j + 1
			summchet++
			flagchet = true
			if summchet >= 2 && flagnechet {
				fmt.Println(lnehet)
				os.Exit(0)
			}
		} else {
			lnehet = j + 1
			summnechet++
			flagnechet = true
			if summnechet >= 2 && flagchet {
				fmt.Println(lchet)
				os.Exit(0)
			}
		}
	}
}

package main

import "fmt"

func main() {

	var n int
	fmt.Scanln(&n)
	var tem int
	var f0 int = 0 // 上上次
	var f1 int = 0 // 上一个
	var f2 int = 0 // 当前
	var arr [100]int

	for i := 0; i < n; i++ {
		fmt.Scan(&tem)
		arr[i] = tem
	}

	f0 = check(arr[0]) //上上个
	f1 = check(arr[1])
	f2 = check(arr[2])
	if f0 == f1 && f1 == f2 && f2 == f0 {

	} else {
		if f0 == f1 {
			fmt.Println(3)
			return
		}
		if f0 == f2 {
			fmt.Println(2)
			return
		}
		if f1 == f2 {
			fmt.Println(0)
			return
		}
	}
	for i := 3; i < n; i++ {
		f0 = f1
		f1 = f2
		f2 = check(arr[i])
		if f2 != f1 {
			fmt.Println(i + 1)
			return
		}

	}

}

func check(i int) int {

	if i%2 == 0 {
		return 0
	} else {
		return 1
	}

}

package main

import "fmt"

func main() {

	var n int
	fmt.Scanln(&n)
	var tem int
	var f0 int = 0 // 上上次
	var f1 int = 0 // 上一个
	var f2 int = 0 // 当前
	f0 = f0
	var arr [100]int

	for i := 0; i < n; i++ {
		fmt.Scanln(&tem)
		arr[i] = tem
	}
	fmt.Println(arr[0], arr[1], arr[2], arr[3])
	f0 = check(arr[0]) //上上个
	f1 = check(arr[1])
	f2 = check(arr[2])

	if f0 == f1 && f1 == f2 && f2 == f0 {

	} else {
		if f0 == f1 {
			fmt.Println(3)
			return
		}
		if f0 == f2 {
			fmt.Println(2)
			return
		}
		if f1 == f2 {
			fmt.Println(0)
			return
		}
	}

	for i := 3; i < n; i++ {

		f0 = f1
		f1 = f2
		f2 = check(arr[i])
		if f2 != f1 {
			fmt.Println(i + 1)
			return
		}

	}

}

func check(i int) int {

	if i%2 == 0 {
		return 0
	} else {
		return 1
	}

}

package main

import "fmt"

func main() {
	var n, a int
	var fo, fe int
	var ec, oc int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a%2 == 0 {
			if ec == 0 {
				fe = i
			}
			ec++
		} else {
			if oc == 0 {
				fo = i
			}
		}
	}
	if ec == 1 {
		fmt.Println(fe + 1)
	} else {
		fmt.Println(fo + 1)
	}
}

package main

import "fmt"

func main() {
	var n, a int
	var fo, fe int
	var ec, oc int
	fe = 0
	fo = 0
	ec = 0
	oc = 0
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a%2 == 0 {
			if ec == 0 {
				fe = i + 1
			}
			ec++
		} else {
			if oc == 0 {
				fo = i + 1
			}
			oc++
		}
	}
	if ec == 1 {
		fmt.Println(fe)
	} else {
		fmt.Println(fo)
	}
}

package main

import "fmt"

func main() {
	var n, a int
	var fo, fe int
	var ec, oc int
	fe = 0
	fo = 0
	ec = 0
	oc = 0
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a%2 == 0 {
			if ec == 0 {
				fe = i
			}
			ec++
		} else {
			if oc == 0 {
				fo = i
			}
			oc++
		}
	}
	if ec == 1 {
		fmt.Println(fe + 1)
	} else {
		fmt.Println(fo + 1)
	}
}

package main

import "fmt"

func main() {
	var n, a int
	var fo, fe int
	var ec, oc int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a)
		if a%2 == 0 {
			if ec == 0 {
				fe = i
			}
			ec++
		} else {
			if oc == 0 {
				fo = i
			}
			oc++
		}
	}
	if ec == 1 {
		fmt.Println(fe + 1)
	} else {
		fmt.Println(fo + 1)
	}
}

package main

import (
    "fmt"
)

func main() {
    n := 0;
    fmt.Scanf("%d", &n);
    a := make([]int, n);
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &a[i]);
    }

    count := 0;
    for i, v := range(a) {
        a[i] = v % 2;
        count += a[i];
    }

    x := 1;

    if (count >= 2) {
        x = 0;
    }

    for i := 0; i < len(a); i++ {
        if a[i] == x {
            fmt.Printf("%d\n", i + 1);
            break;
        }
    }

}

package main

import (
    "fmt"
)

func main() {
    n := 0;
    fmt.Scanf("%d", &n);
    a := make([]int, n);
    for i := 0; i < n; i++ {
        fmt.Scanf("%d", &a[i]);
    }

    count := 0;
    for i, v := range(a) {
        a[i] = v % 2;
        count += a[i];
    }

    x := 1;
    if (count >= 2) {
        x = 0;
    }
    for i := 0; i < count; i++ {
        if a[i] == x {
            fmt.Printf("%d\n", i + 1);
            break;
        }
    }

}