package main

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

// github.com/EndlessCheng/codeforces-go
func CF1494D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ i, j, v int }
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

	var n, v int
	Fscan(in, &n)
	fa := make([]int, n)
	var find func(int) int
	find = func(x int) int {
		if fa[x] != x {
			fa[x] = find(fa[x])
		}
		return fa[x]
	}
	a := make([]pair, 0, n*(n-1)/2)
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			Fscan(in, &v)
			if i < j {
				a = append(a, pair{i, j, v})
			} else if i == j {
				ans[i] = v
				fa[i] = i
			}
		}
	}
	sort.Slice(a, func(i, j int) bool { a, b := a[i], a[j]; return a.v < b.v || a.v == b.v && a.i < b.i })
	pa := make([]int, n)
	for _, p := range a {
		if i, j := find(p.i), find(p.j); i == j {
		} else if max(ans[i], ans[j]) < p.v {
			ans = append(ans, p.v)
			f := len(fa)
			fa = append(fa, f)
			fa[f] = f
			fa[i] = f
			fa[j] = f
			pa = append(pa, f)
			pa[i] = f
			pa[j] = f
		} else if ans[i] == p.v {
			fa[j] = i
			pa[j] = i
		} else {
			fa[i] = j
			pa[i] = j
		}
	}
	Fprintln(out, len(ans))
	for _, v := range ans {
		Fprint(out, v, " ")
	}
	Fprintln(out)
	for i, f := range fa {
		if i == f {
			Fprintln(out, i+1)
			break
		}
	}
	for i, p := range pa {
		if i != p {
			Fprintln(out, i+1, p+1)
		}
	}
}

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

package main

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

var maxno = -1

type tree struct {
	idx      int
	val      int
	children []*tree
}

func splitTree(a [][]int, leaves []int) *tree {
	if len(leaves) == 1 {
		i := leaves[0]
		return &tree{i, a[i][i], nil}
	}

	max := -1
	for _, i := range leaves {
		for _, j := range leaves {
			if max < a[i][j] {
				max = a[i][j]
			}
		}
	}

	l := make([][]int, 0)
	used := make([]bool, 500)
	for _, i := range leaves {
		if used[i] {
			continue
		}
		l = append(l, []int{})
		for _, j := range leaves {
			if a[i][j] < max {
				used[j] = true
				l[len(l)-1] = append(l[len(l)-1], j)
			}
		}
	}

	children := []*tree{}
	for i := range l {
		children = append(children, splitTree(a, l[i]))
	}

	maxno++
	return &tree{idx: maxno, val: max, children: children}
}

func solve(a [][]int) {
	maxno = len(a) - 1
	idxs := []int{}
	for i := range a {
		idxs = append(idxs, i)
	}

	root := splitTree(a, idxs)
	salaries := make([]int, maxno+1)
	edges := make([][2]int, 0)

	var dfs func(*tree)
	dfs = func(u *tree) {
		if u == nil {
			return
		}
		salaries[u.idx] = u.val
		for _, v := range u.children {
			edges = append(edges, [2]int{v.idx, u.idx})
			dfs(v)
		}
	}
	dfs(root)

	printf("%d\n", maxno+1)
	for _, x := range salaries {
		printf("%d ", x)
	}
	printf("\n%d\n", root.idx+1)
	for _, e := range edges {
		printf("%d %d\n", e[0]+1, e[1]+1)
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n int
		scan(&n)

		a := make([][]int, n)
		for i := range a {
			a[i] = make([]int, n)
			for j := range a[i] {
				scan(&a[i][j])
			}
		}

		solve(a)
	}
}

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

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

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

package main

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

func solve(inp [][]int) {
	mp := map[int][][2]int{}
	for i := range inp {
		for j := range inp {
			cost := inp[i][j]
			mp[cost] = append(mp[cost], [2]int{i, j})
		}
	}

	costs := []int{}
	for c := range mp {
		costs = append(costs, c)
	}
	sort.Slice(costs, func(i, j int) bool { return costs[i] < costs[j] })

	d := dsu{}
	for i := range inp {
		d.parent = append(d.parent, i)
		d.rank = append(d.rank, 1)
	}

	nxtempl := len(inp) - 1
	salary := make(map[int]int)
	root := make(map[int]int)
	next := make(map[int]int)

	for _, c := range costs {
		for _, pair := range mp[c] {
			i, j := pair[0], pair[1]
			if i == j {
				root[i] = i
				salary[i] = c
				continue
			}

			seti, setj := d.find(i), d.find(j)
			if seti == setj {
				continue
			}

			rooti, rootj := root[seti], root[setj]
			if salary[rooti] != c {
				rooti, rootj = rootj, rooti
			}

			d.unite(i, j)
			if salary[rooti] != c {
				nxtempl++
				root[d.find(i)] = nxtempl
				salary[nxtempl] = c
				next[rooti] = nxtempl
				next[rootj] = nxtempl
			} else {
				root[d.find(i)] = rooti
				next[rootj] = rooti
			}
		}
	}

	printf("%d\n", nxtempl+1)
	for i := 0; i <= nxtempl; i++ {
		printf("%d ", salary[i])
	}

	for k, v := range salary {
		if v == costs[len(costs)-1] {
			printf("\n%d\n", k+1)
			break
		}
	}
	for i := 0; i < nxtempl; i++ {
		printf("%d %d\n", i+1, next[i]+1)
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n int
		scan(&n)

		a := make([][]int, n)
		for i := range a {
			a[i] = make([]int, n)
			for j := range a[i] {
				scan(&a[i][j])
			}
		}

		solve(a)
	}
}

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

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

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

type dsu struct {
	parent []int
	rank   []int
}

func (d *dsu) find(i int) int {
	if d.parent[i] == i {
		return i
	}
	p := d.find(d.parent[i])
	d.parent[i] = p
	return p
}

func (d *dsu) unite(i, j int) {
	pi := d.find(i)
	pj := d.find(j)
	if pi == pj {
		return
	}

	if d.rank[pi] < d.rank[pj] {
		pi, pj = pj, pi
	}

	d.parent[pj] = pi
	if d.rank[pi] == d.rank[pj] {
		d.rank[pi]++
	}
}

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)
var n, m, k int

type UnionFind struct {
	Fa     []int
	Direct []int
	Groups int // 连通分量个数
}

func NewUnionFind(n int) UnionFind {
	fa := make([]int, n) // n+1
	for i := range fa {
		fa[i] = i
	}
	direct := make([]int, n)
	return UnionFind{fa, direct, n}
}

func (u UnionFind) Find(x int) int {
	if u.Fa[x] != x {
		u.Fa[x] = u.Find(u.Fa[x])
	}
	return u.Fa[x]
}

// newRoot = -1 表示未发生合并
func (u *UnionFind) Merge(from, to int) (newRoot int) {
	x, y := u.Find(from), u.Find(to)
	if x == y {
		return -1
	}
	u.Fa[x] = y
	u.Groups--
	return y
}

func (u UnionFind) Same(x, y int) bool {
	return u.Find(x) == u.Find(y)
}

type edge struct {
	u, v, w int
}
type edges []edge

func (e edges) Len() int      { return len(e) }
func (e edges) Swap(i, j int) { e[i], e[j] = e[j], e[i] }
func (e edges) Less(i, j int) bool {
	if e[i].w != e[j].w {
		return e[i].w < e[j].w
	}
	return e[i].u < e[j].u
}

func main() {
	defer ww.Flush()
	fmt.Fscan(rr, &n)
	p := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		p[i] = make([]int, n+1)
		for j := 1; j <= n; j++ {
			fmt.Fscan(rr, &p[i][j])
		}
	}
	sal := make([]int, n*n)
	cnt := n
	e := make(edges, 0, n*n/2)
	for i := 1; i <= n; i++ {
		for j := i; j <= n; j++ {
			if i == j {
				sal[i] = p[i][j]
			} else {
				e = append(e, edge{i, j, p[i][j]})
			}
		}
	}
	sort.Sort(e)
	uf := NewUnionFind(n * n)
	ans := make([]int, n*n)
	var root int
	for _, val := range e {
		u, v := val.u, val.v
		fa, fb := uf.Find(u), uf.Find(v)
		if fa != fb {
			if val.w > sal[fa] && val.w > sal[fb] {
				cnt++
				root = cnt
				sal[cnt] = val.w
				uf.Merge(fa, cnt)
				uf.Merge(fb, cnt)
				ans[fa] = cnt
				ans[fb] = cnt
			} else if val.w > sal[fa] {
				uf.Merge(fa, fb)
				ans[fa] = fb
			} else if val.w > sal[fb] {
				uf.Merge(fb, fa)
				ans[fb] = fa
			}
		}
	}
	fmt.Fprintln(ww, cnt)
	for i := 1; i <= cnt; i++ {
		fmt.Fprintf(ww, "%d ", sal[i])
	}
	fmt.Fprintln(ww)
	fmt.Fprintln(ww, root)
	for i := 1; i <= cnt; i++ {
		if i != root {
			fmt.Fprintln(ww, i, ans[i])
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	type pair struct{ i, j, v int }

	var n, v int
	Fscan(in, &n)
	fa := make([]int, n)
	var find func(int) int
	find = func(x int) int {
		if fa[x] != x {
			fa[x] = find(fa[x])
		}
		return fa[x]
	}
	a := make([]pair, 0, n*(n-1)/2)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			Fscan(in, &v)
			if i < j {
				a = append(a, pair{i, j, v})
			} else if i == j {
				c[i] = v
				fa[i] = i
			}
		}
	}
	sort.Slice(a, func(i, j int) bool { a, b := a[i], a[j]; return a.v < b.v || a.v == b.v && a.i < b.i })
	pa := make([]int, n)
	for _, p := range a {
		if i, j := find(p.i), find(p.j); i == j {
		} else if c[i] < p.v && c[j] < p.v {
			c = append(c, p.v)
			f := len(fa)
			fa = append(fa, f)
			fa[f] = f
			fa[i] = f
			fa[j] = f
			pa = append(pa, f)
			pa[i] = f
			pa[j] = f
		} else if c[i] == p.v {
			fa[j] = i
			pa[j] = i
		} else {
			fa[i] = j
			pa[i] = j
		}
	}
	Println(len(c))
	for _, v := range c {
		Print(v, " ")
	}
	Println()
	for i, f := range fa {
		if i == f {
			Println(i + 1)
			break
		}
	}
	for i, p := range pa {
		if i != p {
			Println(i+1, p+1)
		}
	}
}

package main

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

func solve(inp [][]int) {
	mp := map[int][][2]int{}
	for i := range inp {
		for j := range inp {
			cost := inp[i][j]
			mp[cost] = append(mp[cost], [2]int{i, j})
		}
	}

	costs := []int{}
	for c := range mp {
		costs = append(costs, c)
	}
	sort.Slice(costs, func(i, j int) bool { return costs[i] < costs[j] })

	d := dsu{}
	for i := range inp {
		d.parent = append(d.parent, i)
		d.rank = append(d.rank, 1)
	}

	nxtempl := len(inp) - 1
	salary := make(map[int]int)
	root := make(map[int]int)
	next := make(map[int]int)

	for _, c := range costs {
		for _, pair := range mp[c] {
			i, j := pair[0], pair[1]
			if i == j {
				root[i] = i
				salary[i] = c
				continue
			}

			seti, setj := d.find(i), d.find(j)
			if seti == setj {
				continue
			}

			rooti, rootj := root[seti], root[setj]
			if salary[rooti] != c {
				rooti, rootj = rootj, rooti
			}

			d.unite(i, j)
			if salary[rooti] != c {
				nxtempl++
				root[d.find(i)] = nxtempl
				salary[nxtempl] = c
				next[rooti] = nxtempl
				next[rootj] = nxtempl
			} else {
				root[d.find(i)] = rooti
				next[rootj] = rooti
			}
		}
	}

	// print ans
	printf("%d\n", nxtempl+1)
	for i := 0; i <= nxtempl; i++ {
		printf("%d ", salary[i])
	}
	printf("\n%d\n", nxtempl)
	for i := 0; i < nxtempl; i++ {
		printf("%d %d\n", i+1, next[i]+1)
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n int
		scan(&n)

		a := make([][]int, n)
		for i := range a {
			a[i] = make([]int, n)
			for j := range a[i] {
				scan(&a[i][j])
			}
		}

		solve(a)
	}
}

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

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

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

type dsu struct {
	parent []int
	rank   []int
}

func (d *dsu) find(i int) int {
	if d.parent[i] == i {
		return i
	}
	p := d.find(d.parent[i])
	d.parent[i] = p
	return p
}

func (d *dsu) unite(i, j int) {
	pi := d.find(i)
	pj := d.find(j)
	if pi == pj {
		return
	}

	if d.rank[pi] < d.rank[pj] {
		pi, pj = pj, pi
	}

	d.parent[pj] = pi
	if d.rank[pi] == d.rank[pj] {
		d.rank[pi]++
	}
}

package main

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

func solve(inp [][]int) {
	mp := map[int][][2]int{}
	for i := range inp {
		for j := range inp {
			cost := inp[i][j]
			mp[cost] = append(mp[cost], [2]int{i, j})
		}
	}

	costs := []int{}
	for c := range mp {
		costs = append(costs, c)
	}
	sort.Slice(costs, func(i, j int) bool { return costs[i] < costs[j] })

	d := dsu{}
	for i := range inp {
		d.parent = append(d.parent, i)
		d.rank = append(d.rank, 1)
	}

	nxtempl := -1
	salary := make(map[int]int)
	root := make(map[int]int)
	next := make(map[int]int)

	for _, c := range costs {
		for _, pair := range mp[c] {
			i, j := pair[0], pair[1]
			if i == j {
				nxtempl++
				root[i] = nxtempl
				salary[nxtempl] = c
				next[i] = nxtempl
				continue
			}

			seti, setj := d.find(i), d.find(j)
			if seti == setj {
				continue
			}

			rooti, rootj := root[seti], root[setj]
			if salary[rooti] != c {
				rooti, rootj = rootj, rooti
			}

			d.unite(i, j)
			if salary[rooti] != c {
				nxtempl++
				root[d.find(i)] = nxtempl
				salary[nxtempl] = c
				next[rooti] = nxtempl
				next[rootj] = nxtempl
			} else {
				root[d.find(i)] = rooti
				next[rootj] = rooti
			}
		}
	}

	printf("%d\n", nxtempl+1)
	for i := 0; i <= nxtempl; i++ {
		printf("%d ", salary[i])
	}
	printf("\n%d\n", nxtempl+1)
	for i := 0; i < nxtempl; i++ {
		printf("%d %d\n", i+1, next[i]+1)
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n int
		scan(&n)

		a := make([][]int, n)
		for i := range a {
			a[i] = make([]int, n)
			for j := range a[i] {
				scan(&a[i][j])
			}
		}

		solve(a)
	}
}

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

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

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

type dsu struct {
	parent []int
	rank   []int
}

func (d *dsu) find(i int) int {
	if d.parent[i] == i {
		return i
	}
	p := d.find(d.parent[i])
	d.parent[i] = p
	return p
}

func (d *dsu) unite(i, j int) {
	pi := d.find(i)
	pj := d.find(j)
	if pi == pj {
		return
	}

	if d.rank[pi] < d.rank[pj] {
		pi, pj = pj, pi
	}

	d.parent[pj] = pi
	if d.rank[pi] == d.rank[pj] {
		d.rank[pi]++
	}
}

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)
var n, m, k int

type UnionFind struct {
	Fa     []int
	Direct []int
	Groups int // 连通分量个数
}

func NewUnionFind(n int) UnionFind {
	fa := make([]int, n) // n+1
	for i := range fa {
		fa[i] = i
	}
	direct := make([]int, n)
	return UnionFind{fa, direct, n}
}

func (u UnionFind) Find(x int) int {
	if u.Fa[x] != x {
		u.Fa[x] = u.Find(u.Fa[x])
	}
	return u.Fa[x]
}

// newRoot = -1 表示未发生合并
func (u *UnionFind) Merge(from, to int) (newRoot int) {
	x, y := u.Find(from), u.Find(to)
	if x == y {
		return -1
	}
	u.Fa[x] = y
	u.Groups--
	return y
}

func (u UnionFind) Same(x, y int) bool {
	return u.Find(x) == u.Find(y)
}

type edge struct {
	u, v int
}

func main() {
	defer ww.Flush()
	fmt.Fscan(rr, &n)
	salary := make([]int, n*n)
	cur := n + 1
	h := make(map[int]int)
	p := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		p[i] = make([]int, n+1)
		for j := 1; j <= n; j++ {
			fmt.Fscan(rr, &p[i][j])
			if i == j {
				salary[i] = p[i][j]
				h[p[i][j]] = i
			} else {
				if _, ok := h[p[i][j]]; !ok {
					h[p[i][j]] = cur
					salary[cur] = p[i][j]
					cur++
				}
			}
		}
	}
	var root, maxv int
	direct := make([]int, n*n)
	for i := 1; i <= n; i++ {
		sort.Ints(p[i])
		for j := 2; j <= n; j++ {
			child, c := h[p[i][j-1]], h[p[i][j]]
			direct[child] = c
			if p[i][j] > maxv {
				root = h[p[i][j]]
				maxv = p[i][j]
			}
		}
	}
	fmt.Fprintln(ww, cur-1)
	for i := 1; i < cur; i++ {
		fmt.Fprintf(ww, "%d ", salary[i])
	}
	fmt.Fprintln(ww)
	fmt.Fprintln(ww, root)
	for i := 1; i < cur; i++ {
		if i != root {
			fmt.Fprintln(ww, i, direct[i])
		}
	}
}

package main

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

var rr = bufio.NewReader(os.Stdin)
var ww = bufio.NewWriter(os.Stdout)
var n, m, k int

type UnionFind struct {
	Fa     []int
	Direct []int
	Groups int // 连通分量个数
}

func NewUnionFind(n int) UnionFind {
	fa := make([]int, n) // n+1
	for i := range fa {
		fa[i] = i
	}
	direct := make([]int, n)
	return UnionFind{fa, direct, n}
}

func (u UnionFind) Find(x int) int {
	if u.Fa[x] != x {
		u.Fa[x] = u.Find(u.Fa[x])
	}
	return u.Fa[x]
}

// newRoot = -1 表示未发生合并
func (u *UnionFind) Merge(from, to int) (newRoot int) {
	x, y := u.Find(from), u.Find(to)
	if x == y {
		return -1
	}
	u.Fa[x] = y
	u.Groups--
	return y
}

func (u UnionFind) Same(x, y int) bool {
	return u.Find(x) == u.Find(y)
}

type edge struct {
	u, v int
}

func main() {
	defer ww.Flush()
	fmt.Fscan(rr, &n)
	salary := make([]int, n*n)
	cur := n + 1
	h := make(map[int]int)
	p := make([][]int, n+1)
	for i := 1; i <= n; i++ {
		p[i] = make([]int, n+1)
		for j := 1; j <= n; j++ {
			fmt.Fscan(rr, &p[i][j])
			if i == j {
				salary[i] = p[i][j]
				h[p[i][j]] = i
			} else {
				if _, ok := h[p[i][j]]; !ok {
					h[p[i][j]] = cur
					salary[cur] = p[i][j]
					cur++
				}
			}
		}
	}
	var root, maxv int
	direct := make([]int, n*n)
	for i := 1; i <= n; i++ {
		sort.Ints(p[i])
		for j := 2; j <= n; j++ {
			child, c := h[p[i][j-1]], h[p[i][j]]
			direct[child] = c
			if p[i][j] > maxv {
				root = h[p[i][j]]
				maxv = p[i][j]
			}
		}
	}
	fmt.Fprintln(ww, root)
	for i := 1; i < cur; i++ {
		fmt.Fprintf(ww, "%d ", salary[i])
	}
	fmt.Fprintln(ww)
	for i := 1; i < cur; i++ {
		if i != root {
			fmt.Fprintln(ww, i, direct[i])
		}
	}
}


package main

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

func shift(b []int64, dist int) []int64 {
	N := len(b) - 1
	nb := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		ni := i + dist
		if ni > N {
			ni %= N
		}
		if ni == 0 {
			ni = N
		}
		nb[ni] = b[i]
	}
	return nb
}

func main() {
	var N int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	N, _ = strconv.Atoi(scanner.Text())
	b := make([]int64, N+1)

	for i := 1; i <= N; i++ {
		scanner.Scan()
		num, _ := strconv.Atoi(scanner.Text())
		b[i] = int64(num)
	}
	b[0] = b[N]

	maxVal := int64(0)
	for i := 1; i <= N; i++ {
		if b[i] > maxVal {
			maxVal = b[i]
		}
	}

	idx := 0
	for i := 1; i <= N; i++ {
		if b[i] == maxVal && b[i-1] < maxVal {
			idx = i
			break
		}
	}
	if idx == 0 {
		if b[1] == 0 {
			fmt.Println("YES")
			fmt.Print(138)
			for i := 2; i <= N; i++ {
				fmt.Print(" ", 138)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}
		return
	}
	fmt.Println("YES")

	b = shift(b, (N - idx))

	sum := int64(0)
	for i := 1; i <= N; i++ {
		sum += b[i]
	}

	a := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		a[i] = sum + b[N]
		sum -= b[i]
	}
	a[N] -= b[N]
	//fmt.Println(a)
	//fmt.Println(idx)
	a = shift(a, idx)

	fmt.Print(a[1])
	for i := 2; i <= N; i++ {
		fmt.Print(" ", a[i])
	}
	fmt.Println()
}

package main

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

var scanner * bufio.Scanner

func next_int()(result int64){
  if !scanner.Scan() {
    panic("Unable to read next integer. Input has no data remain")
  }
  res, err := strconv.ParseInt(scanner.Text(), 10, 32)
  if err != nil {
    panic(err)
  }
  return res
}

func next_str()(result string){
  if !scanner.Scan() {
    panic("Unable to read next token. Input has no data remain")
  }
  return scanner.Text()
}

func print_yes(arr [] int64)(){
  fmt.Println("YES");
  for i := 0; i < len(arr); i++ {
    fmt.Printf("%v ", arr[i])
  }
  return
}

func print_no()(){
  fmt.Println("NO");
  return
}

func main() {

  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)

  n := next_int()
  arr := make([]int64, n, n)
  var zeros int64 = 0
  for i := int64(0); i < n; i++ {
    arr[i] = next_int()
    if 0 == arr[i] {
      zeros++
    }
  }

  if (zeros == n){
    for i := int64(0); i < n; i++{
      arr[i] = 1
    }
    print_yes(arr)
  } else {
    var maxv, maxp int64 = -1, -1
    for i := int64(0); i < n; i++ {
      if (arr[i] >= maxv) {
        maxv = arr[i]
        if (i > 0 && maxv > arr[i-1]) || (i == 0 && maxv > arr[n-1]) {
          maxp = int64(i)
        }
      }
    }
    if maxp == -1 {
      print_no();
    } else {
      ans := make([]int64, n, n)
      ans[maxp] = arr[maxp]
      sum := 3 * arr[maxp]
      for i := (maxp - 1 + n) % n ; i != maxp; i = (i - 1 + n) % n {
        sum += arr[i]
        ans[i] = sum
      }
      print_yes(ans)
    }
  }

  return
}

package main

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

var scanner * bufio.Scanner

func next_int()(result int64){
  if !scanner.Scan() {
    panic("Unable to read next integer. Input has no data remain")
  }
  res, err := strconv.ParseInt(scanner.Text(), 10, 32)
  if err != nil {
    panic(err)
  }
  return res
}

func next_str()(result string){
  if !scanner.Scan() {
    panic("Unable to read next token. Input has no data remain")
  }
  return scanner.Text()
}

func print_yes(arr [] int64)(){
  fmt.Println("YES");
  for i := 0; i < len(arr); i++ {
    fmt.Printf("%v ", arr[i])
  }
  return
}

func print_no()(){
  fmt.Println("NO");
  return
}

func main() {

  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)

  n := int(next_int())
  arr := make([]int64, n, n)
  var zeros int = 0
  for i := 0; i < n; i++ {
    arr[i] = next_int()
    if 0 == arr[i] {
      zeros++
    }
  }

  if (zeros == n){
    for i := 0; i < n; i++{
      arr[i] = 1
    }
    print_yes(arr)
  } else {
    var maxv int64 = -1
    var maxp int = -1
    for i := 0; i < n; i++ {
      if (arr[i] >= maxv) {
        maxv = arr[i]
        if (i > 0 && maxv > arr[i-1]) || (i == 0 && maxv > arr[n-1]) {
          maxp = i
        }
      }
    }
    if maxp == -1 {
      print_no()
    } else {
      ans := make([]int64, n, n)
      ans[maxp] = arr[maxp]
      sum := 3 * arr[maxp]
      for i := (maxp - 1 + n) % n ; i != maxp; i = (i - 1 + n) % n {
        sum += arr[i]
        ans[i] = sum
      }
      print_yes(ans)
    }
  }

  return
}

package main

import "fmt"

func shift(b []int, dist int) []int {
	N := len(b) - 1
	nb := make([]int, N+1)
	for i := 1; i <= N; i++ {
		ni := i + dist
		if ni > N {
			ni %= N
		}
		nb[ni] = b[i]
	}
	return nb
}

func main() {
	var N int
	fmt.Scan(&N)
	b := make([]int, N+1)

	for i := 1; i <= N; i++ {
		fmt.Scan(&b[i])
	}
	b[0] = b[N]

	maxVal := 0
	for i := 1; i <= N; i++ {
		if b[i] > maxVal {
			maxVal = b[i]
		}
	}

	idx := 0
	for i := 1; i <= N; i++ {
		if b[i] == maxVal && b[i-1] < maxVal {
			idx = i
			break
		}
	}
	if idx == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")

	nb := shift(b, (N - idx))

	b = nb
	sum := 0
	for i := 1; i <= N; i++ {
		sum += b[i]
	}

	a := make([]int, N+1)
	for i := 1; i <= N; i++ {
		a[i] = sum + b[N]
		sum -= b[i]
	}
	a[N] -= b[N]
	a = shift(a, idx)

	fmt.Print(a[1])
	for i := 2; i <= N; i++ {
		fmt.Print(" ", a[i])
	}
	fmt.Println()
}

package main

import "fmt"

func shift(b []int64, dist int) []int64 {
	N := len(b) - 1
	nb := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		ni := i + dist
		if ni > N {
			ni %= N
		}
		if ni == 0 {
			ni = N
		}
		nb[ni] = b[i]
	}
	return nb
}

func main() {
	var N int
	fmt.Scan(&N)
	b := make([]int64, N+1)

	for i := 1; i <= N; i++ {
		fmt.Scan(&b[i])
	}
	b[0] = b[N]

	maxVal := int64(0)
	for i := 1; i <= N; i++ {
		if b[i] > maxVal {
			maxVal = b[i]
		}
	}

	idx := 0
	for i := 1; i <= N; i++ {
		if b[i] == maxVal && b[i-1] < maxVal {
			idx = i
			break
		}
	}
	if idx == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")

	b = shift(b, (N - idx))

	sum := int64(0)
	for i := 1; i <= N; i++ {
		sum += b[i]
	}

	a := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		a[i] = sum + b[N]
		sum -= b[i]
	}
	a[N] -= b[N]
	//fmt.Println(a)
	//fmt.Println(idx)
	a = shift(a, idx)

	fmt.Print(a[1])
	for i := 2; i <= N; i++ {
		fmt.Print(" ", a[i])
	}
	fmt.Println()
}

package main

import "fmt"

func shift(b []int64, dist int) []int64 {
	N := len(b) - 1
	nb := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		ni := i + dist
		if ni > N {
			ni %= N
		}
		nb[ni] = b[i]
	}
	return nb
}

func main() {
	var N int
	fmt.Scan(&N)
	b := make([]int64, N+1)

	for i := 1; i <= N; i++ {
		fmt.Scan(&b[i])
	}
	b[0] = b[N]

	maxVal := int64(0)
	for i := 1; i <= N; i++ {
		if b[i] > maxVal {
			maxVal = b[i]
		}
	}

	idx := 0
	for i := 1; i <= N; i++ {
		if b[i] == maxVal && b[i-1] < maxVal {
			idx = i
			break
		}
	}
	if idx == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")

	b = shift(b, (N - idx))

	sum := int64(0)
	for i := 1; i <= N; i++ {
		sum += b[i]
	}

	a := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		a[i] = sum + b[N]
		sum -= b[i]
	}
	a[N] -= b[N]
	a = shift(a, idx)

	fmt.Print(a[1])
	for i := 2; i <= N; i++ {
		fmt.Print(" ", a[i])
	}
	fmt.Println()
}

package main

import "fmt"

func shift(b []int64, dist int) []int64 {
	N := len(b) - 1
	nb := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		ni := i + dist
		if ni > N {
			ni %= N
		}
		if ni == 0 {
			ni = N
		}
		nb[ni] = b[i]
	}
	return nb
}

func main() {
	var N int
	fmt.Scan(&N)
	b := make([]int64, N+1)

	for i := 1; i <= N; i++ {
		fmt.Scan(&b[i])
	}
	b[0] = b[N]

	maxVal := int64(0)
	for i := 1; i <= N; i++ {
		if b[i] > maxVal {
			maxVal = b[i]
		}
	}

	idx := 0
	for i := 1; i <= N; i++ {
		if b[i] == maxVal && b[i-1] < maxVal {
			idx = i
			break
		}
	}
	if idx == 0 {
		if b[1] == 0 {
			fmt.Print(138)
			for i := 2; i <= N; i++ {
				fmt.Print(" ", 138)
			}
			fmt.Println()
		} else {
			fmt.Println("NO")
		}
		return
	}
	fmt.Println("YES")

	b = shift(b, (N - idx))

	sum := int64(0)
	for i := 1; i <= N; i++ {
		sum += b[i]
	}

	a := make([]int64, N+1)
	for i := 1; i <= N; i++ {
		a[i] = sum + b[N]
		sum -= b[i]
	}
	a[N] -= b[N]
	//fmt.Println(a)
	//fmt.Println(idx)
	a = shift(a, idx)

	fmt.Print(a[1])
	for i := 2; i <= N; i++ {
		fmt.Print(" ", a[i])
	}
	fmt.Println()
}

package main

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

var scanner * bufio.Scanner

func next_int()(result int64){
  if !scanner.Scan() {
    panic("Unable to read next integer. Input has no data remain")
  }
  res, err := strconv.ParseInt(scanner.Text(), 10, 32)
  if err != nil {
    panic(err)
  }
  return res
}

func next_str()(result string){
  if !scanner.Scan() {
    panic("Unable to read next token. Input has no data remain")
  }
  return scanner.Text()
}

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

var INF int = 2 * 1000 * 1000 * 1000
var c []int = nil
var next []int = nil
var cost []int = nil
var used []int8 = nil
var stack []int = nil

func check_in_stack(v int)(bool) {
  return (used[v] & 2) > 0
}
func invert_in_stack(v int)() {
  used[v] = used[v] ^ (1 << 1);
  return
}
func is_used(v int)(bool){
  return (used[v] & 1) > 0
}
func set_used(v int)(){
  used[v] = used[v] ^ 1;
}

func get_min_cost(v int)(int, bool){
  set_used(v)
  invert_in_stack(v)
  stack = append(stack, v)

  res := INF
  solved_before := false
  if check_in_stack(next[v]) { // cycle found!
    for j := len(stack)-1; j >= 0; j-- {
      res = min(res, c[stack[j]])
      if stack[j] == next[v] {
        break
      }
    }
  } else if is_used(next[v]) { // it was solved before, just extract the answer
    res = cost[next[v]]
    solved_before = true
  } else { // no cycle, not solved before - go deeper
    ch_res, solved_ch := get_min_cost(next[v])
    res = ch_res
    solved_before = solved_ch
  }

  invert_in_stack(v)
  stack = stack[0:len(stack)-1]
  return res, solved_before
}

func print_yes(arr [] int)(){
  fmt.Println("YES");
  for i := 0; i < len(arr); i++ {
    fmt.Printf("%v ", arr[i])
  }
  return
}

func print_no()(){
  fmt.Println("NO");
  return
}

func main() {

  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)

  n := int(next_int())
  arr := make([]int, n, n)
  var zeros int = 0
  for i := 0; i < n; i++ {
    arr[i] = int(next_int())
    if 0 == arr[i] {
      zeros++
    }
  }

  if (zeros == n){
    print_yes(arr)
  } else {
    var maxv, maxp int = -1, -1
    for i := 0; i < n; i++ {
      if (arr[i] >= maxv) {
        maxv = arr[i]
        if (i > 0 && maxv > arr[i-1]) || (i == 0 && maxv > arr[n-1]) {
          maxp = i
        }
      }
    }
    if maxp == -1 {
      print_no();
    } else {
      ans := make([]int, n, n)
      ans[maxp] = arr[maxp]
      sum := 3 * arr[maxp]
      for i := (maxp - 1 + n) % n ; i != maxp; i = (i - 1 + n) % n {
        sum += arr[i]
        ans[i] = sum
      }
      print_yes(ans)
    }
  }

  return
}

package main

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

var scanner * bufio.Scanner

func next_int()(result int64){
  if !scanner.Scan() {
    panic("Unable to read next integer. Input has no data remain")
  }
  res, err := strconv.ParseInt(scanner.Text(), 10, 32)
  if err != nil {
    panic(err)
  }
  return res
}

func next_str()(result string){
  if !scanner.Scan() {
    panic("Unable to read next token. Input has no data remain")
  }
  return scanner.Text()
}

func print_yes(arr [] int)(){
  fmt.Println("YES");
  for i := 0; i < len(arr); i++ {
    fmt.Printf("%v ", arr[i])
  }
  return
}

func print_no()(){
  fmt.Println("NO");
  return
}

func main() {

  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)

  n := int(next_int())
  arr := make([]int, n, n)
  var zeros int = 0
  for i := 0; i < n; i++ {
    arr[i] = int(next_int())
    if 0 == arr[i] {
      zeros++
    }
  }

  if (zeros == n){
    for i := 0; i < n; i++{
      arr[i] = 1
    }
    print_yes(arr)
  } else {
    var maxv, maxp int = -1, -1
    for i := 0; i < n; i++ {
      if (arr[i] >= maxv) {
        maxv = arr[i]
        if (i > 0 && maxv > arr[i-1]) || (i == 0 && maxv > arr[n-1]) {
          maxp = i
        }
      }
    }
    if maxp == -1 {
      print_no();
    } else {
      ans := make([]int, n, n)
      ans[maxp] = arr[maxp]
      sum := 3 * arr[maxp]
      for i := (maxp - 1 + n) % n ; i != maxp; i = (i - 1 + n) % n {
        sum += arr[i]
        ans[i] = sum
      }
      print_yes(ans)
    }
  }

  return
}


package main

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

type heap struct {
  array []int
}

func (h *heap) push(val int) {
  h.array = append(h.array, val)
  cur := len(h.array) - 1
  for cur > 0 {
    var parent int
    if (cur & 1) == 1 {
      parent = (cur - 1) / 2
    } else {
      parent = (cur - 2) / 2
    }
    if h.array[cur] < h.array[parent] {
      h.array[cur], h.array[parent] = h.array[parent], h.array[cur]
      cur = parent
    } else {
      break
    }
  }
}

func (h *heap) pop() int {
  res := h.array[0]
  h.array[0], h.array[len(h.array)-1] = h.array[len(h.array)-1], h.array[0]
  h.array = h.array[:len(h.array)-1]
  cur := 0
  for cur < len(h.array) {
    smallest := cur
    if cur*2+1 < len(h.array) && h.array[smallest] > h.array[cur*2+1] {
      smallest = cur*2 + 1
    }
    if cur*2+2 < len(h.array) && h.array[smallest] > h.array[cur*2+2] {
      smallest = cur*2 + 2
    }
    if smallest != cur {
      h.array[smallest], h.array[cur] = h.array[cur], h.array[smallest]
      cur = smallest
    } else {
      break
    }
  }
  return res
}

func main() {
  in := bufio.NewReader(os.Stdin)
  out := bufio.NewWriter(os.Stdout)
  defer out.Flush()
  var n, k int
  Fscan(in, &n, &k)
  var v0, v1 int
  cnt := make(map[int]int)
  for i := 0; i <= k; i++ {
    Fprint(out, "?")
    for j := 0; j <= k; j++ {
      if j == i {
        continue
      }
      Fprint(out, " ", j+1)
    }
    Fprint(out, "\n")
    out.Flush()
    Fscan(in, &v0, &v1)
    cnt[v1]++
  }
  number, ans := 0, 0
  for k, v := range cnt {
    if k > number {
      number, ans = k, v
    }
  }
  Fprintln(out, "!", ans)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line := strings.Split(readLine(reader), " ")

	k := parseInt(line[1])
	ans := make([]int, k+1)

	maxVal := -1
	for i := range ans {
		fmt.Print("? ")
		for j := 0; j < k+1; j++ {
			if j != i {
				fmt.Print(j+1, " ")
			}
		}
		fmt.Println()
		ans[i] = parseInt(strings.Split(readLine(reader), " ")[1])
		if ans[i] > maxVal {
			maxVal = ans[i]
		}
	}

	m := 0
	for _, x := range ans {
		if x == maxVal {
			m++
		}
	}

	fmt.Println("!", m)
}

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

func parseInt(s string) int {
	v, err := strconv.ParseInt(s, 10, 64)
	checkError(err)
	return int(v)
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')
	if err == io.EOF {
		return ""
	}

	return strings.TrimSpace(str)
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	q := 1
	//fmt.Fscanf(in, "%d\n", &q)
	for ii := 0; ii < q; ii++ {
		n, k := 0, 0
		v1, v2 := -1, -1
		v1Cnt, v2Cnt := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &k)
		for i := 0; i < k+1; i++ {
			first := true
			for j := 0; j < k+1; j++ {
				if j != i {
					if !first {
						fmt.Fprintf(out, " %d", j+1)
					} else {
						fmt.Fprintf(out, "? %d", j+1)
						first = false
					}
				}
			}
			fmt.Fprintf(out, "\n")
			out.Flush()
			pos, value := 0, 0
			fmt.Fscanf(in, "%d %d\n", &pos, &value)
			if v1Cnt == 0 {
				v1 = value
				v1Cnt++
			} else if value == v1 {
				v1Cnt++
			} else {
				v2 = value
				v2Cnt++
			}
		}
		if v1 > v2 {
			v1, v2 = v2, v1
			v1Cnt, v2Cnt = v2Cnt, v1Cnt
		}
		fmt.Fprintf(out, "! %d\n", v2Cnt)
		out.Flush()
	}
	return
}

func min(a, b int64) int64 {
	if a == -1 {
		return b
	}
	if b == -1 {
		return a
	}
	if a < b {
		return a
	}
	return b
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	q := 1
	//fmt.Fscanf(in, "%d\n", &q)
	for ii := 0; ii < q; ii++ {
		n, k := 0, 0
		v1, v2 := -1, -1
		v1Cnt, v2Cnt := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &k)
		for i := 0; i < k+1; i++ {
			first := true
			for j := 0; j < k+1; j++ {
				if j != i {
					if !first {
						fmt.Fprintf(out, " %d", j+1)
					} else {
						fmt.Fprintf(out, "%d", j+1)
						first = false
					}
				}
			}
			fmt.Fprintf(out, "\n")
			out.Flush()
			pos, value := 0, 0
			fmt.Fscanf(in, "%d %d\n", &pos, &value)
			if v1Cnt == 0 {
				v1 = value
				v1Cnt++
			} else if value == v1 {
				v1Cnt++
			} else {
				v2 = value
				v2Cnt++
			}
		}
		if v1 > v2 {
			v1, v2 = v2, v1
			v1Cnt, v2Cnt = v2Cnt, v1Cnt
		}
		fmt.Fprintf(out, "%d\n", v2Cnt+1)
		out.Flush()
	}
	return
}

func min(a, b int64) int64 {
	if a == -1 {
		return b
	}
	if b == -1 {
		return a
	}
	if a < b {
		return a
	}
	return b
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	q := 1
	//fmt.Fscanf(in, "%d\n", &q)
	for ii := 0; ii < q; ii++ {
		n, k := 0, 0
		v1, v2 := -1, -1
		v1Cnt, v2Cnt := 0, 0
		fmt.Fscanf(in, "%d %d\n", &n, &k)
		for i := 0; i < k+1; i++ {
			first := true
			for j := 0; j < k+1; j++ {
				if j != i {
					if !first {
						fmt.Fprintf(out, " %d", j+1)
					} else {
						fmt.Fprintf(out, "? %d", j+1)
						first = false
					}
				}
			}
			fmt.Fprintf(out, "\n")
			out.Flush()
			pos, value := 0, 0
			fmt.Fscanf(in, "%d %d\n", &pos, &value)
			if v1Cnt == 0 {
				v1 = value
				v1Cnt++
			} else if value == v1 {
				v1Cnt++
			} else {
				v2 = value
				v2Cnt++
			}
		}
		if v1 > v2 {
			v1, v2 = v2, v1
			v1Cnt, v2Cnt = v2Cnt, v1Cnt
		}
		fmt.Fprintf(out, "! %d\n", v2Cnt+1)
		out.Flush()
	}
	return
}

func min(a, b int64) int64 {
	if a == -1 {
		return b
	}
	if b == -1 {
		return a
	}
	if a < b {
		return a
	}
	return b
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line := strings.Split(readLine(reader), " ")

	k := parseInt(line[1])
	ans := make([]int, k+1)

	maxVal := -1
	for i := range ans {
		fmt.Print("? ")
		for j := 0; j < k+1; j++ {
			if j != i {
				fmt.Print(j+1, " ")
			}
		}
		fmt.Println()
		ans[i] = parseInt(strings.Split(readLine(reader), " ")[0])
		if ans[i] > maxVal {
			maxVal = ans[i]
		}
	}

	m := 0
	for _, x := range ans {
		if x == maxVal {
			m++
		}
	}

	fmt.Println("!", m)
}

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

func parseInt(s string) int {
	v, err := strconv.ParseInt(s, 10, 64)
	checkError(err)
	return int(v)
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')
	if err == io.EOF {
		return ""
	}

	return strings.TrimSpace(str)
}

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

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line := strings.Split(readLine(reader), " ")

	k := parseInt(line[1])
	ans := make([]int64, k+1)

	maxVal := int64(-1)
	for i := range ans {
		fmt.Print("? ")
		for j := int64(0); j < k+1; j++ {
			if j != int64(i) {
				fmt.Print(j+1, " ")
			}
		}
		fmt.Println()
		ans[i] = parseInt(strings.Split(readLine(reader), " ")[0])
		if ans[i] > maxVal {
			maxVal = ans[i]
		}
	}

	m := 0
	for _, x := range ans {
		if x == maxVal {
			m++
		}
	}

	fmt.Println("!", m)
}

func readInt(reader *bufio.Reader) int64 {
	return parseInt(readLine(reader))
}

func parseInt(s string) int64 {
	v, err := strconv.ParseInt(s, 10, 64)
	checkError(err)
	return int64(v)
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')
	if err == io.EOF {
		return ""
	}

	return strings.TrimSpace(str)
}

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

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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	line := strings.Split(readLine(reader), " ")

	k := parseInt(line[1])
	ans := make([]int, k+1)

	maxVal := -1
	for i := range ans {
		fmt.Print("?")
		for j := 0; j < k+1; j++ {
			if j != i {
				fmt.Print(j+1, " ")
			}
		}
		fmt.Println()
		ans[i] = parseInt(strings.Split(readLine(reader), " ")[0])
		if ans[i] > maxVal {
			maxVal = ans[i]
		}
	}

	m := 0
	for _, x := range ans {
		if x == maxVal {
			m++
		}
	}

	fmt.Println("!", m)
}

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

func parseInt(s string) int {
	v, err := strconv.ParseInt(s, 10, 64)
	checkError(err)
	return int(v)
}

func readLine(reader *bufio.Reader) string {
	str, err := reader.ReadString('\n')
	if err == io.EOF {
		return ""
	}

	return strings.TrimSpace(str)
}

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

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

package main

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

type heap struct {
  array []int
}

func (h *heap) push(val int) {
  h.array = append(h.array, val)
  cur := len(h.array) - 1
  for cur > 0 {
    var parent int
    if (cur & 1) == 1 {
      parent = (cur - 1) / 2
    } else {
      parent = (cur - 2) / 2
    }
    if h.array[cur] < h.array[parent] {
      h.array[cur], h.array[parent] = h.array[parent], h.array[cur]
      cur = parent
    } else {
      break
    }
  }
}

func (h *heap) pop() int {
  res := h.array[0]
  h.array[0], h.array[len(h.array)-1] = h.array[len(h.array)-1], h.array[0]
  h.array = h.array[:len(h.array)-1]
  cur := 0
  for cur < len(h.array) {
    smallest := cur
    if cur*2+1 < len(h.array) && h.array[smallest] > h.array[cur*2+1] {
      smallest = cur*2 + 1
    }
    if cur*2+2 < len(h.array) && h.array[smallest] > h.array[cur*2+2] {
      smallest = cur*2 + 2
    }
    if smallest != cur {
      h.array[smallest], h.array[cur] = h.array[cur], h.array[smallest]
      cur = smallest
    } else {
      break
    }
  }
  return res
}

func main() {
  in := bufio.NewReader(os.Stdin)
  out := bufio.NewWriter(os.Stdout)
  defer out.Flush()
  var n, k int
  Fscan(in, &n, &k)
  var v0, v1 int
  cnt := make(map[int]int)
  for i := 0; i <= k; i++ {
    Fprint(out, "?")
    for j := 0; j <= k; j++ {
      if j == i {
        continue
      }
      Fprint(out, " ", j+1)
    }
    Fprint(out, "\n")
    out.Flush()
    Fscan(in, &v0, &v1)
    cnt[v1]++
  }
  ans := 0
  for _, v := range cnt {
    if v > ans {
      ans = v
    }
  }
  Fprintln(out, "!", ans)
}


package main

import (
	"fmt"
)

func main() {
	var (
		n, x int
		s    string
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		if s[1] == '+' {
			x++
		} else {
			x--
		}
	}
	fmt.Print(x)
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	nTemp, err := strconv.ParseInt(readLine(reader), 10, 64)

	checkError(err)
	x := int(nTemp)
	res := 0
	for i := 0; i < x; i++ {
		out := readLine(reader)
		if out == "++X" || out == "X++" {
			res++
		} else {
			res--
		}
	}
	fmt.Println(res)
}

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

package main

import( "fmt" )

func main() {

	var n, y int
	var s string

	fmt.Scan( &n )
	for i := 0 ; i < n ; i++ {

	fmt.Scan( &s )
	if( s == "++X" || s ==  "X++" ){ y++ }else if( s == "--X" || s ==  "X--" ){ y-- }else{ fmt.Println( "error" ) }

	}

	fmt.Println( y )

}

package main

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

var writer *bufio.Writer
var scanner *bufio.Scanner

func main() {
	ini()
	defer writer.Flush()

	n := scanInt()
	var result int
	for i:=0; i<n; i++ {
		iter := scanString()
		if strings.Contains(iter, "++") {
			result++
		} else {
			result--
		}
	}

	writer.WriteString(strconv.Itoa(result))

}

func ini() {
	scanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
	scanner.Split(bufio.ScanWords)
}

func scanInt() int {
	scanner.Scan()
	i, _ := strconv.Atoi(scanner.Text())
	return i
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

package main

import (
	"fmt"
)

func main() {
	var n, rez int
	var st string

	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&st)
		if string([]rune(st)[1]) == "+" {
			rez++
		} else {
			rez--
		}
	}

	fmt.Print(rez)
}

package main

import "fmt"

func main() {

	var x string
	var X, n int

	fmt.Scan(&n)

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

		fmt.Scan(&x)
		switch x[0] {
		case '+':
			X = X + 1
			continue
		case '-':
			X = X - 1
			continue
		}

		switch x[2] {
		case '+':
			X = X + 1
			continue
		case '-':
			X = X - 1
			continue
		}

	}

	fmt.Print(X)
}

package main

import "fmt"

func main() {

	var x [150]string
	var X, n int

	fmt.Scan(&n)

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

		fmt.Scan(&x[i])
	}
looper:
	for i := 0; i < n; i++ {
		temp := x[i]

		switch temp[0] {
		case '+':
			X = X + 1
			continue looper
		case '-':
			X = X - 1
			continue looper
		}

		switch temp[2] {
		case '+':
			X = X + 1
			continue looper
		case '-':
			X = X - 1
			continue looper
		}
		//fmt.Printf("x[%v] = '%s'\n", i, x[i])
	}
	fmt.Print(X)
}

package main

import "fmt"

func main() {
	var n int
	var inp string
	fmt.Scan(&n)
	answer := 0
	for i:=0; i<n; i++ {
		fmt.Scan(&inp)
		if inp[1]=='+' {
			answer++
		} else {
			answer--
		}
	}
	fmt.Print(answer)
}

/*A. Bit++
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.

The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:

Operation ++ increases the value of variable x by 1.
Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.

A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.

You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).

Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.

Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.

Output
Print a single integer — the final value of x.

Examples
inputCopy
1
++X
outputCopy
1
inputCopy
2
X++
--X
outputCopy
0
*/

package main

import "fmt"

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

	for i := 0; i < numberOfLines; i++ {
		var operation string
		fmt.Scanf("%s\n", &operation)

		switch operation {
		case "X++", "++X":

			counter++
		case "--X", "X--":
			counter--
		}
	}
	fmt.Println(counter)
}

/*A. Bit++
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
The classic programming language of Bitland is Bit++. This language is so peculiar and complicated.

The language is that peculiar as it has exactly one variable, called x. Also, there are two operations:

Operation ++ increases the value of variable x by 1.
Operation -- decreases the value of variable x by 1.
A statement in language Bit++ is a sequence, consisting of exactly one operation and one variable x. The statement is written without spaces, that is, it can only contain characters "+", "-", "X". Executing a statement means applying the operation it contains.

A programme in Bit++ is a sequence of statements, each of them needs to be executed. Executing a programme means executing all the statements it contains.

You're given a programme in language Bit++. The initial value of x is 0. Execute the programme and find its final value (the value of the variable when this programme is executed).

Input
The first line contains a single integer n (1 ≤ n ≤ 150) — the number of statements in the programme.

Next n lines contain a statement each. Each statement contains exactly one operation (++ or --) and exactly one variable x (denoted as letter «X»). Thus, there are no empty statements. The operation and the variable can be written in any order.

Output
Print a single integer — the final value of x.

Examples
inputCopy
1
++X
outputCopy
1
inputCopy
2
X++
--X
outputCopy
0
*/

package main

import "fmt"

func main() {
	var numberOfLines, counter int
	fmt.Scanln(&numberOfLines)

	var operation string
	for i := 0; i < numberOfLines; i++ {
		fmt.Scanln(&operation)

		switch operation {
		case "X++", "++X":

			counter++
		case "--X", "X--":
			counter--
		}
	}
	fmt.Println(counter)
}

package main

import "fmt"

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

	count := 0

	for n > 0 {
		var input string
		fmt.Scan(&input)
		if input[1] == '+' {
			count++
		} else {
			count--
		}
		n--
	}

	fmt.Println(count)

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var x int = 0
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		if s[1] == '+' {
			x++
		} else {
			x--
		}
	}
	fmt.Println(x)
}

package main

import f "fmt"

func main (){
	var n int
  f.Scanln(&n)
	var oper [150]string

	for i:=0; i < n; i++ {
		f.Scanln(&oper[i])
	}

	x := 0
	for i:= 0; i < n; i++ {
		if oper[i] == "X++" || oper[i] == "++X" {
			x++
		}else{
			x--
		}
	}
	f.Println(x)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint16
	var c int32 = 0
	var s string
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; uint16(i) < n; i++ {
		fmt.Fscanf(in, "%s\n", &s)
		if s == "++X" || s == "X++" {
			c++
		} else if s == "--X" || s == "X--" {
			c--
		}
	}
	fmt.Println(c)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	var res int
	for i := 0; i < n; i++ {
		var line string
		fmt.Scan(&line)
		if strings.Contains(line, "++") {
			res++
		} else if strings.Contains(line, "--") {
			res--
		}
	}
	fmt.Print(res)
}

package main

import fmt "fmt"
func do( result int,s string ) int {
	if (s[0]=='+'|| (s[0]=='X'&&s[1]=='+')){
		return result+1;
	} else {
		return result-1;
	}
}

func main() {
	var x int;
	var result int;
	var v string;

	result = 0;
	fmt.Scanf("%d\n",&x);
	for i := 0; i < x; i++ {
		fmt.Scanf("%s\n",&v);
		result = do(result,v);
	}

	fmt.Print(result);
}

package main

import "fmt"

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

package main

import "fmt"

func main() {
	var T int
	fmt.Scanf("%d\n", &T)
	var s string;
	ans := 0
	for i := 0; i < T; i++ {
		fmt.Scanf("%s\n", &s)
		if s[1] == '+' {
			ans ++
		} else {
			ans --
		}
	}
	fmt.Printf("%d\n", ans)
}

package main

import (
	"fmt"
	"strings"
)

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

	x := 0
	for i := 0; i < n; {
		var p string
		fmt.Scanf("%s", &p)
		if len(p) == 0 {
			continue
		}
		if strings.Contains(p, "+") {
			x++
		} else if strings.Contains(p, "-") {
			x--
		}
		i++
	}
	fmt.Println(x)
}

package main

import (
	"fmt"
	"strings"
)

func main() {

	var n int
	fmt.Scan(&n)
	var x int = 0
	for i := 0; i < n; i++ {
		var command string
		fmt.Scan(&command)
		if strings.Compare("X++", command) == 0 || strings.Compare("++X", command) == 0 {
			x++
		} else if strings.Compare("X--", command) == 0 || strings.Compare("--X", command) == 0 {
			x--
		}
	}
	fmt.Print(x)
}

package main

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

var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

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

func main() {
	defer writer.Flush()

	scanner := bufio.NewScanner(os.Stdin)
	n := 0
	result := 0
	for i := 0; scanner.Scan(); i++ {
		// First line
		if i == 0 {
			params := StringToArrayInt(scanner.Text())
			n = params[0] // number of lines
		} else {
			result = Run(scanner.Text(), result)
		}

		// Exit condition
		if i >= n {
			break
		}
	}

	printf("%d", result)
}

func Run(operation string, operand int) int {
	if strings.Contains(operation, "++") {
		return operand + 1
	}
	return operand - 1
}

// Utils
func StringToArrayInt(t string) (t2 []int) {
	for _, i := range strings.Split(t, " ") {
		j, err := strconv.Atoi(i)
		if err != nil {
			panic(err)
		}
		t2 = append(t2, j)
	}
	return t2
}

func ArrayStringToInt(t []string) (t2 []int) {
	for _, i := range t {
		j, err := strconv.Atoi(i)
		if err != nil {
			panic(err)
		}
		t2 = append(t2, j)
	}
	return t2
}

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

var scanner * bufio.Scanner = bufio.NewScanner(os.Stdin)

func scanInt() int{
    scanner.Scan()
    var i int
    i,_ = strconv.Atoi(scanner.Text())
    return i
}

func scanStr() string{
    scanner.Scan()
    return scanner.Text()
}

func main(){
    n := scanInt()
    cnt := 0
    for i := 0; i < n; i++ {

        str := scanStr()
        if( str[1:2] == "-" ){
            cnt--
        } else {
            //fmt.Println("bal")
            cnt++
        }
    }
    fmt.Println(cnt)
}

package main

import (
    "fmt"
    "strings"
)

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

    cnt := 0
    for i:=0; i < t; i++ {
        var s string
        fmt.Scan(&s)
        if strings.Contains(s, "+") {
            cnt++
            continue
        }
        cnt--
    }
    fmt.Println(cnt)
}

package main

import (
	"fmt"
	"strings"
)

func main() {

	var n, x int
	var op string

	fmt.Scanf("%d\n", &n)

	for i := 1; i <= n; i++{
		fmt.Scanf("%s\n", &op)

		if strings.ContainsRune(op, '+'){
			x++
		} else{
			x--
		}
	}

	fmt.Printf("%d\n", x)

}

package main

import "fmt"

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

	var b []byte
	for i := n; i > 0; i-- {
		if fmt.Scan(&b); b[1] == '-' {
			n-=2
		}
	}
	fmt.Println(n)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
    var num int
    var s string
    var cnt int

    cnt = 0

	fmt.Scanf("%d\n", &num)

    for i := 0; i < num; i++ {
        fmt.Scanf("%s\n", &s)

        if strings.Index(s,"+")>=0 {
        	cnt = cnt + 1
        }

        if strings.Index(s,"-")>=0 {
        	cnt = cnt - 1
        }
    }
    fmt.Printf("%d",cnt)
}

package main

import (
	"fmt"
	"strings"
)

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

	for i := 0; i < n; i++ {
		var str string
		fmt.Scanf("%s\n", &str)

		if strings.Contains(str, "+") {
			x++
		} else {
			x--
		}
	}

	fmt.Printf("%d", x)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		x, n int
	)
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanf("%s\n", &s)
		if strings.Contains(s, "X++") {
			x++
		} else if strings.Contains(s, "++X") {
			x++
		} else if strings.Contains(s, "--X") {
			x--
		} else if strings.Contains(s, "X--") {
			x--
		}
	}
	fmt.Printf("%d\n", x)
}

package main

import "fmt"

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

package main

import (
	"fmt"
)

func main() {
	var N, cnt int
	var x string
	fmt.Scanln(&N)
	for i := 0; i < N; i++ {
		fmt.Scanln(&x)
		if x == "++X" || x == "X++" {
			cnt++
		} else if x == "--X" || x == "X--" {
			cnt--
		}
	}
	fmt.Println(cnt)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		n     int
		count int
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		if strings.Contains(s, "+") {
			count++
		} else {
			count--
		}
	}

	fmt.Println(count)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	x := 0
	var s string
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		if strings.ContainsRune(s, '+') {
			x++
			continue
		}
		x--
	}
	fmt.Print(x)
}

package main

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

func main() {
	fmt.Println(parsInputs())
}

func parsInputs() int {
	in := getInputs()
	x := 0
	for _, opt := range in {
		if strings.Contains(opt, "++") {
			x++
		} else if strings.Contains(opt, "--") {
			x--
		}
	}
	return x
}

func getInputs() []string {
	reader := bufio.NewReader(os.Stdin)
	l := -1
	current := 0
	opts := []string{}

	for current != l {
		s, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}
		s = strings.TrimRight(s, "\r\n")

		if l == -1 {
			l, _ = strconv.Atoi(s)
			continue
		}
		opts = append(opts, s)
		current++
	}
	return opts
}

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...); writer.Flush();}
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f+"\n", a...); }

func main() {
    var n int;
    scanf("%d", &n);
    var x int = 0;
    var s string;
    for i:=0;i<n;i++ {
        scanf("%s", &s);
        if s[1] == '+' {
            x++;
        } else {
            x--;
        }
    }
    printf("%d", x);
}

package main

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

func main() {
	var n int
	var x int

	_, err := fmt.Scanf("%d", &n)
	if err != nil {
		fmt.Println(err)
		return
	}

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	for i := 0; i < n && scanner.Scan(); i++ {
		text := scanner.Text()
		if text == "++X" || text == "X++" {
			x++
		} else if text == "--X" || text == "X--" {
			x--
		}
	}

	fmt.Println(x)
}

package main

import (
	"fmt"
)

func main() {
	var bitland []string
	number := 0
	_, _ = fmt.Scanln(&number)
	for number > 0 {
		var istring string
		_, _ = fmt.Scanln(&istring)
		bitland = append(bitland, istring)
		number--
	}
	var count int32 = 0

	for i := 0; i < len(bitland); i++ {
		if string(bitland[i]) == "++X" {
			count++
		} else if string(bitland[i]) == "X++" {
			count++
		} else {
			count--
		}
	}

	fmt.Println(count)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n,c int
	var word string
	fmt.Scan(&n)
	c = 0
	for ; n>0; n--{
		fmt.Scan(&word)

		if strings.Contains(word, "++") {
			c++
		} else {
			c--
		}
	}

	fmt.Print(c)
}

package main

import ("fmt")
import ("strings")

func main() {
  var num int
  result:=0
  fmt.Scanln(&num)
  for i:=0;i<num;i++{
    var current string
    fmt.Scanln(&current)

     if strings.Contains(current, "+") {
       result++
    } else {
      result--
    }
  }
      fmt.Println(result)

}

package main

import "fmt"

func main() {
	var x, n int
	var line string

	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s\n", &line)
		if line[1] == '+' {
			x++
		} else {
			x--
		}
	}

	fmt.Println(x)
}

package main

import "fmt"

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

	cnt := 0

	for t := 0; t < test_case; t++ {
		var str string
		fmt.Scan(&str)

		if str[0] == '+' || str[2] == '+' {
			cnt++
		} else if str[0] == '-' || str[2] == '-' {
			cnt--
		}
	}

	fmt.Println(cnt)
}

package main

import (
	"fmt"
)
func main ( ){
	var len, out int
	var cmd string
	fmt.Scanln(&len)

	for i := 0; i < len; i++ {
		fmt.Scanln(&cmd)
		switch cmd{
			case "X++":
			out++
			case "++X":
			out++
			case "X--":
			out--
			case "--X":
			out--
		}
	}
	fmt.Println(out)
}

package main

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

func nextWords(scanner *bufio.Scanner) []string {
	scanner.Scan()
	return strings.Fields(scanner.Text())
}

func nextNumbers(scanner *bufio.Scanner) []int {
	var numbers = make([]int, 0)
	line := nextWords(scanner)
	for i := range line {
		n, _ := strconv.Atoi(line[i])
		numbers = append(numbers, n)
	}
	return numbers
}

func nextInt(scanner *bufio.Scanner) int {
	number, _ := strconv.Atoi(nextLine(scanner))
	return number
}

func sumInputs(numbers []int) int {
	var sum int
	for i := range numbers {
		sum += numbers[i]
	}
	return sum
}

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)
	var x = 0

	n := nextInt(scanner)

	for n < 1 || n > 150 {
		n = nextInt(scanner)
	}

	for i := 0; i < n; i++ {
		stm := nextLine(scanner)
		o:=stm[1:2]

		if o == "+" {
			x++
		} else {
			x = x - 1
		}
	}

	fmt.Println(x)
}

//初始值为0
//如果是++X或者X++则加1 --X或者X--则减
package main

import (
	"fmt"
)

func main() {
	var num, result int
	fmt.Scanln(&num)
	array := make([]string, num+1)
	result = 0
	for i := 1; i <= num; i++ {
		fmt.Scanln(&array[i])
		if array[i] == "++X" || array[i] == "X++" {
			result++
		} else {
			result--
		}
	}
	fmt.Println(result)

}

package main

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

func main() {
	scanner := bufio.NewScanner(bufio.NewReader(os.Stdin))
	scanner.Scan()
	n := int32(0)
	fmt.Sscanf(scanner.Text(), "%d", &n)

	ans := 0
	for scanner.Scan() {
		s := scanner.Text()
		if strings.Contains(s, "+") {
			ans++
		} else {
			ans--
		}
	}
	fmt.Println(ans)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	x := 0

	for i := 0; i < n; i++ {
		scanner.Scan()
		op := scanner.Text()

		if strings.Contains(op, "++") {
			x++
		} else {
			x--
		}
	}

	fmt.Println(x)
}

package main

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

func main() {
	n := scanInt()
	var x = 0
	for ; n > 0; n-- {
		operation := scanString()
		if operation == "X++" || operation == "++X" {
			x++
		} else {
			x--
		}
	}
	_, _ = printFmt(x)
}

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

var channelType chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var printFmt func(a ...interface{}) (n int, err error)

func init() {
	printFmt = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func scanString() string {in.Scan(); return in.Text() }
func scanInt() int {i, _ := strconv.Atoi(scanString()); return i}
func scanInt64() int64 {i, _ := strconv.ParseInt(scanString(), 10, 64); return i}
func scanStringSlice(n int) []string {s := make([]string, n); for i := 0; i < n; i++ {s[i] = scanString()}; return s}
func scanIntSlice(n int) []int {arr := make([]int, n); for i := 0; i < n; i++ {arr[i] = scanInt()}; return arr}
func scanInt64Slice(n int) []int64 {arr := make([]int64, n); for i := 0; i < n; i++ {arr[i] = scanInt64()}; return arr}

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

func stringEquivalent(v interface{}) string {return fmt.Sprintf("%v", v)}
func spaceSeperatedStringFromArray(a []int) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.Itoa(a[i]) + " ")}; return sb.String()}
func spaceSeperatedStringFromArray64(a []int64) string {sb := strings.Builder{}; sb.Grow(len(a) * 9); for i := range a {sb.WriteString(strconv.FormatInt(a[i], 10) + " ")}; return sb.String()}
func minMaxFromArray(args ...int64) (int64, int64) {minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64); for _, v := range args {if v < minVal {minVal = v}; if v > maxVal {maxVal = v}}; return minVal, maxVal}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64 {return a / gcdCalculation(a, b) * b}
func gcdCalculation(a, b int64) int64 {if a == 0 {return b}; return gcdCalculation(b%a, a)}
func sortInt64Slice(a []int64) {sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })}
func absoluteValue(x int64) int64 {if x < 0 {return -x}; return x}
func min(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func max(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func sorting(array []int64, fromElement int, toElement int) []int64 {
	var arr []int64
	for i := fromElement; i <= toElement; i++ {
		arr = append(arr, array[i])
	}
	sort.Slice(arr, func(i, j int) bool { return arr[i] < arr[j] })
	s := 0
	for i := fromElement; i <= toElement; i++ {
		array[i] = arr[s]
		s++
	}
	return array
}

func reverse(numbers []int64) []int64 {
	for i, j := 0, len(numbers)-1; i < j; i, j = i+1, j-1 {
		numbers[i], numbers[j] = numbers[j], numbers[i] }
	return numbers
}

func reversing(array []int64, fromElement int, toElement int) []int64 {
	var arr []int64
	for i := fromElement; i <= toElement; i++ {
		arr = append(arr, array[i])
	}
	arr = reverse(arr)
	s := 0
	for i := fromElement; i <= toElement; i++ {
		array[i] = arr[s]
		s++
	}
	return array
}

package main

import "fmt"

func main() {
	x := 0
	n := 0
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		s := ""
		fmt.Scanf("%s\n", &s)
		if s[0] == '+' || s[len(s)-1] == '+' {
			x++
			continue
		}
		x--
	}
	fmt.Println(x)
}

package main

import (
    "fmt"
)

type i int32

func main(){
    var n,res i
    fmt.Scan(&n)
    res = 0
    for n>0{
        var s string
        fmt.Scan(&s)
        if s=="X++" || s=="++X"{
            res++
        }else if s=="X--" || s=="--X" {
            res--
        }
        n--
    }
    fmt.Println(res)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n , ans int
	var s string
	fmt.Scan(&n)
	for i:=0; i<n; i++{
		fmt.Scan(&s)
		if strings.Compare(string(s[0]),string("+")) == 0 || strings.Compare(string(s[2]),string("+")) == 0 {
				ans++
			}else{
				ans--
			}
	}
	fmt.Println(ans)
	return
}

package main

import "fmt"

func main() {
	x := 0
	n := 0
	fmt.Scanf("%d\n", &n)
	for i := 0; i < n; i++ {
		var s string
		fmt.Scanln(&s)
		if s[0] == '+' || s[len(s)-1] == '+' {
			x++
			continue
		}
		x--
	}
	fmt.Println(x)
}

package main

import (
	"fmt"
)

func isPlus(k string) bool {
	f := false
	if k == "X++" || k == "++X" {
		f = true
	}
	return f
}

func main() {
	var n, m int
	var st string
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&st)
		if isPlus(st) {
			m++
		} else {
			m--
		}
	}
	fmt.Println(m)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	// tokens: --, ++, X
	// each line contains operator AND variable => aka statement
	// each line contaisn ONE statement
	// rule out X b/c it will always be there.
	// just need to know if a stmt has - or +. then we inc/dec depnding onti.

	// inputs
	num_stmt := 0
	fmt.Scan(&num_stmt)

	total := 0
	for num_stmt > 0 {
		stmt := ""
		fmt.Scan(&stmt)

		if strings.Contains(stmt, "++") {
			total++
		} else {
			total--
		}
		num_stmt--
	}
	fmt.Println(total)
}

package main

import "fmt"

func main() {
	var n int
	var op string

	x := 0
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&op)
		switch op {
		case "++X", "X++":
			x++
		case "--X", "X--":
			x--
		}
	}
	fmt.Println(x)
}

package main

import "fmt"

func main() {
	var n int
	var st string
	fmt.Scan(&n)
	result := 0
	for ; n > 0; n-- {
		fmt.Scan(&st)
		var b byte = st[1]
		if b == '+' {
			result++
		} else {
			result--
		}
	}
	fmt.Println(result)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var b []byte
	for i := n; i > 0; i-- {
		if fmt.Scan(&b); b[1] == '-' {
			n -= 2
		}
	}
	fmt.Print(n)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	result := 0
	for i := 0; i < n; i++ {
		var st string
		fmt.Scan(&st)
		if strings.Contains(st, "+") {
			result++
		} else {
			result--
		}
	}
	fmt.Println(result)
}

package main

import (
	"fmt"
	"strings"
)

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

	answer := 0

	for i := 0; i < m; i++ {
		var x string
		fmt.Scan(&x)

		if strings.Contains(x, "++") {
			answer++
		} else if strings.Contains(x, "--") {
			answer--
		}
	}

	fmt.Println("", answer)
}

package main

import "fmt"

func task_solution(a []string) (ans int) {
	for _, str := range a {
		// check central symbol of string
		if str[1] == '+' {
			ans += 1
		} else {
			ans -= 1
		}
	}
	return ans
}

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

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

	fmt.Println(task_solution(a))
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	var x int
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		if strings.Contains(s, "++") {
			x++
		} else if strings.Contains(s, "--") {
			x--
		}
	}
	fmt.Println(x)
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/282/A

package main

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

func Solve(ops []string) int {
	x := 0
	for _, op := range ops {
		if op == "++X" || op == "X++" {
			x += 1
		} else if op == "--X" || op == "X--" {
			x -= 1
		}
	}
	return x
}

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

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

	fmt.Fprintf(writer, "%d\n", Solve(ops))
}

package main

import (
	"fmt"
)

func main(){
	var n int
	fmt.Scanln(&n)
	var x int
	for i := 0; i < n; i++ {
		var expr string
		fmt.Scanln(&expr)
		if expr[1] == '-'{
			x--
		} else {
			x++
		}
	}
	fmt.Println(x)
}

package main

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

const ADDING_OPERATION = "++"
const SUBSTRACTING_OPERRATION = "--"

func main() {
	input := bufio.NewScanner(os.Stdin)
	hasInput := input.Scan()
	if hasInput == false {
		panic("Number of problems missing")
	}

	_, err := strconv.Atoi(input.Text())

	if err != nil {
		panic("Undefined number passed")
	}

	x := 0
	for input.Scan() {
		operation := input.Text()
		if strings.Contains(operation, ADDING_OPERATION) {
			x++

		} else {
			x--
		}
	}

	fmt.Println(x)
}

package main

import "fmt"

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

	var b []byte
	for i := n; i > 0; i-- {
		if fmt.Scan(&b); b[1] == '-' {
			n--
		}
	}
	fmt.Println(n)
}

package main

import "fmt"

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

	var b []byte
	for i := n; i > 0; i-- {
		if fmt.Scan(&b); b[1] == '-' {
			n=-2
		}
	}
	fmt.Println(n)
}

package main

import "fmt"
import "strings"

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

	for i := 0; i < n; i++ {
		var str string
		fmt.Scanf("%s", &str)

		if strings.Contains(str, "+") {
			x++
		} else {
			x--
		}
	}

	fmt.Printf("%d", x)
}

package main

import (
	"fmt"
	"strings"
)

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

	for i := 0; i < n; i++ {
		var str string
		fmt.Scanf("%s", &str)

		if strings.Contains(str, "+") {
			x++
		} else {
			x--
		}
	}

	fmt.Printf("%d", x)
}

package main

import "fmt"

func main() {
	var n int
	var input string
	fmt.Scanln("%d", &n)
	ans := 0
	for i := 0; i < n; i++ {
		fmt.Scanln("%s", &input)
		if string(input[1]) == "-" {
			ans--
		} else {
			ans++
		}
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
)

func main() {
	var (
		n, x int
		s    string
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		if s[2] == '+' {
			x++
		} else {
			x--
		}
	}
	fmt.Print(x)
}

package main

import ("fmt")
import ("strings")

func main() {
  var num int
  result:=0
  fmt.Scanln(&num)
  for i:=0;i<num;i++{
    var current string
    fmt.Scanln(&current)

     if strings.Contains(current, "+") {
       result++
    } else {
      result--
    }
    fmt.Println(result)

  }
}

package main

import (
    "fmt"
)

type ui uint32

func main(){
    var n,res ui
    fmt.Scan(&n)
    res = 0
    for n>0{
        var s string
        fmt.Scan(&s)
        if s=="X++" || s=="++X"{
            res++
        }else if s=="X--" || s=="--X" {
            res--
        }
        n--
    }
    fmt.Println(res)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n , ans int
	var s string
	fmt.Scan(&n)
	for ; n>0; n--{
		fmt.Scan(&s)
		if strings.Compare(string(s[0]),string("+")) == 0{
				ans++
			}else{
				ans--
			}
	}
	fmt.Println(ans)
	return
}

package main

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

const ADDING_OPERATION = "X++"
const SUBSTRACTING_OPERRATION = "--X"

func main() {
	input := bufio.NewScanner(os.Stdin)
	hasInput := input.Scan()
	if hasInput == false {
		panic("Number of problems missing")
	}

	_, err := strconv.Atoi(input.Text())

	if err != nil {
		panic("Undefined number passed")
	}

	x := 0
	for input.Scan() {
		switch operation := input.Text(); operation {
			case ADDING_OPERATION:
				x++
			case SUBSTRACTING_OPERRATION:
				x--
		}
	}

	fmt.Println(x)
}

package main

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

const ADDING_OPERATION = "++X"
const SUBSTRACTING_OPERRATION = "--X"

func main() {
	input := bufio.NewScanner(os.Stdin)
	hasInput := input.Scan()
	if hasInput == false {
		panic("Number of problems missing")
	}

	_, err := strconv.Atoi(input.Text())

	if err != nil {
		panic("Undefined number passed")
	}

	x := 0
	for input.Scan() {
		operation := input.Text()
		switch operation {
			case ADDING_OPERATION:
				x++
			case SUBSTRACTING_OPERRATION:
				x--
		}
	}

	fmt.Println(x)
}

package main

import (
	"fmt"
  "strings"
)

func main() {
  var n int
  var s string
  var num int
  for i:=0; i<n ; i++ {
	  fmt.Scanf("%s\n", &s)
    if( strings.ContainsAny(s, "+") ){
        num++;
    }else{
      num--
    }

  }

  fmt.Println(num)

}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, i uint8
	var s string
	fmt.Scanln(&n)
	for n > 0 {
		n--
		fmt.Scanln(&s)
		switch {
		case strings.Contains(s, "+"):
			i++
		case strings.Contains(s, "-"):
			i--
		}
	}
	fmt.Println(i)
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint16
	var c uint32 = 0
	var s string
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; uint16(i) < n; i++ {
		fmt.Fscanf(in, "%s\n", &s)
		if s == "++X" || s == "X++" {
			c++
		} else if s == "--X" || s == "X--" {
			c--
		}
	}
	fmt.Println(c)
}

package main

import fmt "fmt"
func do( result int,s string ) int {
	if (s[0]=='+'|| (s[0]=='X'&&s[1]=='+')){
		return result+1;
	} else {
		return result-1;
	}
}

func main() {
	var x int;
	var result int;
	var v string;

	result = 0;
	fmt.Scanf("%d\n",&x);
	for i := 0; i < x-1; i++ {
		fmt.Scanf("%s\n",&v);
		result = do(result,v);
	}
	fmt.Scanf("%s\n",&v);
	if(v[0]!='X'){
		result = do(result,v);
	}
	fmt.Print(result);
}

package main

import fmt "fmt"
func do( result int,s string ) int {
	if (s[0]=='+'|| (s[0]=='X'&&s[1]=='+')){
		return result+1;
	} else {
		return result-1;
	}
}

func main() {
	var x int;
	var result int;
	result = 0;
	fmt.Scanf("%d\n",&x);
	for i := 0; i < x-1; i++ {
		var v string;
		fmt.Scanf("%s\n",&v);
		result = do(result,v);
	}
	var v string;
	fmt.Scanf("%s\n",&v);
	if(v[0]!='X'){
		result = do(result,v);
	}
	fmt.Print(result);
}

package main

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

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

	scanner := bufio.NewScanner(os.Stdin)
	x := 0
	for i := 0; i < n && scanner.Scan(); i++ {
		p := scanner.Text()
		if strings.Contains(p, "+") {
			x++
		} else if strings.Contains(p, "-") {
			x--
		}
	}
	fmt.Println(x)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var inc string = "X++"
	var dcr string = "--X"

	var n int
	fmt.Scan(&n)
	var x int = 0
	for i := 0; i < n; i++ {
		var command string
		fmt.Scan(&command)
		if strings.Compare(inc, command) == 0 {
			x++
		} else if strings.Compare(dcr, command) == 0 {
			x--
		}
	}
	fmt.Print(x)
}

package main

import (
        "fmt"
)

var fuckMap = map[string]int{
        "X++": 1,
        "++X": 1,
        "X--": -1,
        "--X": -1,
}

func main() {
        var (
                inputnum int
                input    string
        )
        fmt.Scan(&inputnum)
        output := 0
        for i := 0; i < inputnum; i++ {
                fmt.Scanf("%s", &input)
                output += fuckMap[input]
        }
        fmt.Println(output)
}

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

var scanner * bufio.Scanner = bufio.NewScanner(os.Stdin)

func scanInt() int{
    scanner.Scan()
    var i int
    i,_ = strconv.Atoi(scanner.Text())
    return i
}

func scanStr() string{
    scanner.Scan()
    return scanner.Text()
}

func main(){
    n := scanInt()
    cnt := 0
    for i := 0; i < n; i++ {
        str := scanStr()
        if( str[0:1] == "+" ){
            cnt++
        } else {
            cnt--
        }
    }
    fmt.Println(cnt)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n,c int
	var word string
	fmt.Scan(&n)
	c = 0
	for ; n>0; n--{
		fmt.Scanln(&word)

		if (strings.Contains(word, "++")) {
			c++
		} else {
			c--
		}
	}

	fmt.Print(c)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n,c int
	var word string
	fmt.Scan(&n)
	c = 0
	for ; n>0; n--{
		fmt.Scanln(&word)

		if strings.Contains(word, "++") {
			c++
		} else {
			c--
		}
	}

	fmt.Print(c)
}

package main
import ("fmt")
func main() {
    var n int
    var s string
    fmt.Scan(&n)
    val:=0
    for i:=0;i<n;i++ {
        fmt.Scan(&s)
        if s=="--X" {
            val--
        } else if s=="++X" {
            val++
        } else if s=="X--" {
            if i==n-1 {
                continue
            } else {
                val--
            }
        } else {
            if i==n-1 {
                continue
            } else {
                val++
            }
        }
    }
    fmt.Println(val)
}

package main

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

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

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	x := 0

	for i := 0; i < n; i++ {
		scanner.Scan()
		op := scanner.Text()

		fmt.Println(op)

		if strings.Contains(op, "++") {
			x++
		} else {
			x--
		}
	}

	fmt.Println(x)
}

package main

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

func main() {
	values, _ := strconv.Atoi(readLine())

	initialValue := 0

	for i := 0; i < values; i++ {
		commandStr := readLine()
		if commandStr == "X++" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" {
			initialValue = initialValue - 1
		}

	}

	fmt.Print(initialValue)

}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	if scanner.Scan() {
		return scanner.Text()

	}
	return ""
}

package main

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

func main() {
	values, _ := strconv.Atoi(readLine())

	initialValue := 0

	for i := 0; i < values; i++ {
		commandStr := readLine()
		if commandStr == "X++" || commandStr == "++X" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" || commandStr == "X--" {
			initialValue = initialValue - 1
		}

	}

	fmt.Print(initialValue)

}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	if scanner.Scan() {
		return scanner.Text()

	}
	return ""
}

package main

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

func main() {
	values, _ := strconv.Atoi(readLine())

	initialValue := 0

	for i := 0; i < values; i++ {
		commandStr := readLine()
		if commandStr == "X++" || commandStr == "++X" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" || commandStr == "X--" {
			initialValue = initialValue - 1
		}

	}

	fmt.Print(initialValue)

}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return scanner.Text()

}

package main

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

func main() {
	values, _ := strconv.Atoi(readLine())

	initialValue := 0

	for i := 0; i < values; i++ {
		commandStr := readLine()
		if commandStr == "X++" || commandStr == "++X" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" || commandStr == "X--" {
			initialValue = initialValue - 1
		}

	}

	fmt.Print(initialValue)

}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return strings.TrimSpace(scanner.Text())

}

package main

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

func main() {
	initialValue, _ := strconv.Atoi(readLine())

	for true {
		commandStr := readLine()
		if commandStr == "X++" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" {
			initialValue = initialValue - 1
		} else {
			fmt.Print(initialValue)
			break
		}

	}
}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	if scanner.Scan() {
		return scanner.Text()

	}
	return ""
}

package main

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

func main() {
	values, _ := strconv.Atoi(readLine())

	initialValue := 0

	for i := 0; i < values; i++ {
		commandStr := readLine()
		if commandStr == "X++" || commandStr == "++X" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" || commandStr == "X--" {
			initialValue = initialValue - 1
		}

	}

	fmt.Println(initialValue)

}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return strings.TrimSpace(scanner.Text())
}

package main

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

func main() {
	values, _ := strconv.Atoi(readLine())

	initialValue := 0

	for i := 0; i < values; i++ {
		commandStr := readLine()
		if commandStr == "X++" || commandStr == "++X" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" || commandStr == "X--" {
			initialValue = initialValue - 1
		} else {
			initialValue = -99
		}

	}

	fmt.Println(initialValue)

}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return strings.TrimSpace(scanner.Text())
}

package main

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

func main() {
	values, _ := strconv.Atoi(readLine())

	initialValue := 0

	for i := 0; i < values; i++ {
		commandStr := readLine()
		if commandStr == "X++" || commandStr == "++X" {
			initialValue = initialValue + 1
		} else if commandStr == "--X" || commandStr == "X--" {
			initialValue = initialValue - 1
		} else {
			fmt.Println("Unknown value:" + commandStr)
			initialValue = -99
		}

	}

	fmt.Println(initialValue)

}

func readLine() string {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	return strings.TrimSpace(scanner.Text())
}


package main

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

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

	var n, q int
	fmt.Fscan(in, &n, &q)

	aa := make([]int, 50+1)
	for i := range aa {
		aa[i] = -1
	}
	for i := 0; i < n; i++ {
		var v int
		fmt.Fscan(in, &v)
		if aa[v] < 0 {
			aa[v] = i
		}
	}

	for i := 0; i < q; i++ {
		var v int
		fmt.Fscan(in, &v)

		fmt.Fprintf(out, "%d ", aa[v]+1)
		for i, k := range aa {
			if k < 0 || k >= aa[v] {
				continue
			}
			aa[i]++
		}
		aa[v] = 0
	}
	fmt.Fprintln(out)

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, q, b int
	type card struct{ color, index int }
	Fscan(in, &n, &q)
	colors := [51]bool{}
	cards := make([]card, 0)
	for i := 0; i < n; i++ {
		Fscan(in, &b)
		if !colors[b] {
			colors[b] = true
			cards = append(cards, card{color: b, index: i})
		}
	}
	for i := 0; i < q; i++ {
		Fscan(in, &b)
		for j, c := range cards {
			if c.color == b {
				Fprint(out, c.index+1, " ")
				nextCards := []card{{color: b, index: 0}}
				for k := 0; k < j; k++ {
					cc := cards[k]
					cc.index++
					nextCards = append(nextCards, cc)
				}
				nextCards = append(nextCards, cards[j+1:]...)
				cards = nextCards
				break
			}
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	type pair struct{ v, i int }
	var n, v, q int
	Fscan(in, &n, &q)
	a := []pair{}
	s := [51]bool{}
	for i := 1; i <= n; i++ {
		Fscan(in, &v)
		if !s[v] {
			s[v] = true
			a = append(a, pair{v, i})
		}
	}
	for ; q > 0; q-- {
		Fscan(in, &v)
		for i, p := range a {
			if p.v == v {
				Fprint(out, p.i, " ")
				b := []pair{{v, 1}}
				for _, q := range a[:i] {
					b = append(b, pair{q.v, q.i + 1})
				}
				a = append(b, a[i+1:]...)
				break
			}
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ v, i int }
	var n, v, q int
	Fscan(in, &n, &q)
	a := []pair{}
	vis := [51]bool{}
	for i := 1; i <= n; i++ {
		Fscan(in, &v)
		if !vis[v] {
			vis[v] = true
			a = append(a, pair{v, i})
		}
	}
	for i := 0; i < q; i++ {
		Fscan(in, &v)
		for j, p := range a {
			if p.v == v {
				Fprint(out, p.i, " ")
				b := []pair{{v, 1}}
				for _, q := range a[:j] {
					b = append(b, pair{q.v, q.i + 1})
				}
				b = append(b, a[j+1:]...)
				a = b
				break
			}
		}
	}
}

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

package main

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

func run(or io.Reader, ow io.Writer) {
	in := bufio.NewReader(or)
	out := bufio.NewWriter(ow)
	defer out.Flush()

	type pair struct {
		first  int
		second int
	}
	solve := func() {
		var n, q int
		fmt.Fscan(in, &n, &q)
		vis := make([]int, 50)
		var a []pair
		for i := 0; i < n; i++ {
			var t int
			fmt.Fscan(in, &t)
			t--
			if vis[t] == 0 {
				vis[t] = 1
				a = append(a, pair{t, i})
			}
		}
		for ; q > 0; q-- {
			var t int
			fmt.Fscan(in, &t)
			t--
			for i := 0; i < len(a); i++ {
				if a[i].first == t {
					fmt.Fprint(out, a[i].second+1, " ")
					o := a[i]
					o.second = 0
					a = append(a[:i], a[i+1:]...)
					a = append([]pair{o}, a...)
					break
				}
				a[i].second++
			}

		}
		fmt.Fprintln(out)

	}

	T := 1
	//fmt.Fscan(in, &T)
	for o := 0; o < T; o++ {
		solve()
	}

}

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

package main

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

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}
func (s *Scanner) Next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}
func (s *Scanner) NextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt()
	}
	return res
}
func (s *Scanner) NextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt64()
	}
	return res
}
func Min(nums ...int) int {
	ans := math.MaxInt32
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}
func Max(nums ...int) int {
	ans := math.MinInt32
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	N := sc.NextInt()
	Q := sc.NextInt()
	arr := sc.NextInts(N)

	minIdx := make([]int, 55)
	for i := 0; i < 55; i++ {
		minIdx[i] = -1
	}
	for i := 0; i < N; i++ {
		if minIdx[arr[i]] == -1 {
			minIdx[arr[i]] = i
		}
	}

	for i := 0; i < Q; i++ {
		t := sc.NextInt()
		fmt.Fprint(wr, minIdx[t]+1, " ")
		for j := 0; j < 55; j++ {
			if minIdx[j] < minIdx[t] {
				minIdx[j]++
			}
		}
		minIdx[t] = 0
	}
	fmt.Fprintln(wr)

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m

}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	var n, q int
	fmt.Fscan(input, &n)
	fmt.Fscan(input, &q)

	ARRAY := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		fmt.Fscan(input, &ARRAY[i])
	}
	ANOTHER := make([]int, 51)
	for i := n; i > 0; i-- {
		ANOTHER[ARRAY[i]] = i
	}
	// fmt.Println(ANOTHER)
	for j := 0; j < q; j++ {
		var TJ int
		fmt.Fscan(input, &TJ)
		fmt.Println(ANOTHER[TJ])
		w := ANOTHER[TJ]
		for i := 1; i < 51; i++ {
			if i == TJ {
				ANOTHER[i] = 1
			} else {
				if ANOTHER[i] != 0 && ANOTHER[i] < w {
					ANOTHER[i]++
				}
			}
		}
		// fmt.Println(ANOTHER)
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, q, b int
	type card struct{ color, index int }
	Fscan(in, &n, &q)
	colors := [51]bool{}
	cards := make([]card, 0)
	for i := 0; i < n; i++ {
		Fscan(in, &b)
		if !colors[b] {
			colors[b] = true
			cards = append(cards, card{color: b, index: i})
		}
	}
	for i := 0; i < q; i++ {
		Fscan(in, &b)
		fmt.Printf("%+v\n", cards)
		for j, c := range cards {
			if c.color == b {
				Fprint(out, c.index+1, " ")
				nextCards := []card{{color: b, index: 0}}
				for k := 0; k < j; k++ {
					cc := cards[k]
					cc.index++
					nextCards = append(nextCards, cc)
				}
				nextCards = append(nextCards, cards[j+1:]...)
				cards = nextCards
				break
			}
		}

	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, q, b int
	Fscan(in, &n, &q)
	cards := make([]int, n)
	for i := 0; i < n; i++ {
		Fscan(in, &b)
		cards[i] = b
	}
	for i := 0; i < q; i++ {
		Fscan(in, &b)
		idx := -1
		for j, card := range cards {
			if b == card {
				Fprint(out, idx+1, " ")
				idx = j
				ncards := []int{card}
				ncards = append(ncards, cards[:idx]...)
				cards = append(ncards, cards[idx+1:]...)
				break
			}
		}
	}
}