Once upon a time Mike and Mike decided to come up with an outstanding problem for some stage of ROI (rare olympiad in informatics). One of them came up with a problem prototype but another stole the idea and proposed that problem for another stage of the same olympiad. Since then the first Mike has been waiting for an opportunity to propose the original idea for some other contest... Mike waited until this moment!You are given an array $$$a$$$ of $$$n$$$ integers. You are also given $$$q$$$ queries of two types:  Replace $$$i$$$-th element in the array with integer $$$x$$$.  Replace each element in the array with integer $$$x$$$. After performing each query you have to calculate the sum of all elements in the array.

The first line contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n, q \le 2 \cdot 10^5$$$) — the number of elements in the array and the number of queries, respectively. The second line contains $$$n$$$ integers $$$a_1, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$) — elements of the array $$$a$$$. Each of the following $$$q$$$ lines contains a description of the corresponding query. Description begins with integer $$$t$$$ ($$$t \in \{1, 2\}$$$) which denotes a type of the query:   If $$$t = 1$$$, then two integers $$$i$$$ and $$$x$$$ are following ($$$1 \le i \le n$$$, $$$1 \le x \le 10^9$$$) — position of replaced element and it's new value.  If $$$t = 2$$$, then integer $$$x$$$ is following ($$$1 \le x \le 10^9$$$) — new value of each element in the array.

Print $$$q$$$ integers, each on a separate line. In the $$$i$$$-th line print the sum of all elements in the array after performing the first $$$i$$$ queries.

NoteConsider array from the example and the result of performing each query:  Initial array is $$$[1, 2, 3, 4, 5]$$$.  After performing the first query, array equals to $$$[5, 2, 3, 4, 5]$$$. The sum of all elements is $$$19$$$.  After performing the second query, array equals to $$$[10, 10, 10, 10, 10]$$$. The sum of all elements is $$$50$$$.  After performing the third query, array equals to $$$[10, 10, 10, 10, 11$$$]. The sum of all elements is $$$51$$$.  After performing the fourth query, array equals to $$$[10, 10, 10, 1, 11]$$$. The sum of all elements is $$$42$$$.  After performing the fifth query, array equals to $$$[1, 1, 1, 1, 1]$$$. The sum of all elements is $$$5$$$.

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint64 {
	var input [][]uint64
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint64 {
	var result []uint64
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint64(i))
	}
	return result
}

func sumOnce(array []uint64) uint64 {
	result := uint64(0)
	for _, v := range array {
		result += v
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint64(0)
	positions := map[uint64]uint64{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint64(query[1])
			rep := uint64(query[2])
			//fmt.Println(positions)
			if _, ok := positions[pos-1]; ok {
				sum = sum + (rep - positions[pos-1])
			} else if i != 0 {
				sum = sum + rep - i
			} else {
				sum = sum + rep - a[pos-1]
			}
			positions[pos-1] = rep
			//positions[pos-1] =
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			rep := query[1]
			i = rep
			positions = map[uint64]uint64{}
			sum = n * i
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint64 {
	var input [][]uint64
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint64 {
	var result []uint64
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint64(i))
	}
	return result
}

func sumOnce(array []uint64) uint64 {
	result := uint64(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint64, pos uint64, replacement uint64) []uint64 {
	array[pos] = replacement
	return array
}

func q2(array []uint64, replacement uint64) []uint64 {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint64, e uint64) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint64, positions []uint64) uint64 {
	result := uint64(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint64, positions []uint64) uint64 {
	result := uint64(0)
	for p := range a {
		if !contains(positions, uint64(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint64(0)
	positions := map[uint64]uint64{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint64(query[1])
			rep := uint64(query[2])
			//fmt.Println(positions)
			if _, ok := positions[pos-1]; ok {
				sum = sum + (rep - positions[pos-1])
			} else if i != 0 {
				sum = sum + rep - i
			} else {
				sum = sum + rep - a[pos-1]
			}
			positions[pos-1] = rep
			//positions[pos-1] =
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			rep := query[1]
			i = rep
			positions = map[uint64]uint64{}
			sum = n * i
		}
		fmt.Println(sum)
	}
}

package main

import (
	"bufio"
	_ "embed"
	"fmt"
	"os"
)

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

func main() {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()
	defer w.Flush()
	var n, q int
	fmt.Fscan(r, &n, &q)
	arr := make([]uint64, n)
	var sum uint64 = 0
	var firstAll bool
	var lastAll uint64 = 0
	marked := make(map[int]bool)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &arr[i])
		sum += arr[i]
	}
	for q > 0 {
		var t int
		fmt.Fscan(r, &t)
		if t == 1 {
			var i int
			var x uint64
			fmt.Fscan(r, &i, &x)
			if firstAll {
				if _, ok := marked[i-1]; !ok {
					marked[i-1] = true
					arr[i-1] = lastAll
				}
			}
			sum = sum - arr[i-1] + x
			arr[i-1] = x

		} else {
			fmt.Fscan(r, &lastAll)
			sum = uint64(n) * lastAll
			firstAll = true
			marked = make(map[int]bool)
		}
		fmt.Fprintln(w, sum)
		q--
	}
}

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)

	arr := make([]int64, n)
	var sum int64
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &arr[i])
		sum += arr[i]
	}

	d := int64(-1)
	var g int
	m := make([]int, n)
	for i := 0; i < q; i++ {
		var t int
		fmt.Fscan(in, &t)
		if t == 1 {
			var idx int
			var x int64
			fmt.Fscan(in, &idx, &x)
			sum += x
			if m[idx-1] != g && d >= 0 {
				sum -= d
				m[idx-1] = g
			} else {
				sum -= arr[idx-1]
			}
			arr[idx-1] = x
		} else {
			var x int64
			fmt.Fscan(in, &x)
			d = x
			g++
			sum = int64(n) * x
		}
		fmt.Fprintln(out, sum)
	}
}

package main

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

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

func CF1670B(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var n, q int64
	var total int64
	fmt.Fscan(r, &n, &q)
	arr := make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(r, &arr[i])
		total += arr[i]
	}

	m := make(map[int64]int64)
	setAll, allVal := false, int64(0)
	for j := int64(0); j < q; j++ {
		var t, i, x int64
		fmt.Fscan(r, &t)

		switch t {
		case 1:
			fmt.Fscan(r, &i, &x)
			originalVal := arr[i-1]
			if setAll {
				originalVal = allVal
			}
			v, ok := m[i]
			if ok {
				originalVal = v
			}
			total += x - originalVal
			m[i] = x

		case 2:
			fmt.Fscan(r, &x)
			total = n * x
			m = make(map[int64]int64)
			setAll = true
			allVal = x
		}

		fmt.Fprintln(w, total)
	}

}

package main

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

func main_div2_791_B() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	//Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n, q int
		Fscan(in, &n, &q)
		var total, x, setVal int64
		a := make([]int64, n)
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
			total += a[i]
		}
		var set bool
		aly := make(map[int]bool, 0)
		for i := 0; i < q; i++ {
			var t, p int
			Fscan(in, &t)
			if t == 1 {
				Fscan(in, &p, &x)
				p--
				if set && !aly[p] {
					a[p] = setVal
					aly[p] = true
				}
				total += (x - a[p])
				a[p] = x
			} else {
				Fscan(in, &x)
				total = x * int64(n)
				set = true
				setVal = x
				temp := make(map[int]bool)
				aly = temp
			}
			Fprintln(out, total)
		}
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() {
	main_div2_791_B()
}

package main

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

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

func main() {
	scanner := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var ntests int
	//fmt.Fscan(scanner, &ntests)
	ntests = 1
	for iter := 0; iter < ntests; iter++ {
		var n, q int
		fmt.Fscan(scanner, &n, &q)
		var sum int64 = 0
		slice := make([]int64, n)
		it := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(scanner, &slice[i])
			sum += slice[i]
		}
		niter := 0
		currallelem := int64(0)
		for i := 0; i < q; i++ {
			var tmp int
			fmt.Fscan(scanner, &tmp)
			switch tmp {
			case 1:
				var iel, x int64
				fmt.Fscan(scanner, &iel, &x)
				iel--
				if it[iel] == niter {
					sum += x - slice[iel]
				} else {
					sum += x - currallelem
				}
				slice[iel] = x
				it[iel] = niter
			case 2:
				fmt.Fscan(scanner, &currallelem)
				niter++
				sum = int64(n) * currallelem
			}
			fmt.Fprintln(writer, sum)
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
type node struct { sum,cnt int64 }
func lstop(a,b node) node { return node{a.sum+b.sum,a.cnt+b.cnt} }
func lstmap(f int, a node) node { if f == -1 { return a } else { return node{int64(f) * a.cnt,a.cnt}} }
func lstcmp(f int, g int) int { if f == -1 { return g } else { return f } }
type lazysegtree struct {
	n, size, log int; op func(node, node) node; mapping func(int, node) node
	composition func(int, int) int; e node; id int; d []node; lz []int
}
func Newlazysegtree(n int, op func(node, node) node, mapping func(int, node) node, composition func(int, int) int, e node, id int) *lazysegtree {
	v := make([]node, n); for i := 0; i < n; i++ { v[i] = e }
	return NewlazysegtreeVec(v, op, mapping, composition, e, id)
}
func NewlazysegtreeVec(v []node, op func(node, node) node, mapping func(int, node) node, composition func(int, int) int, e node, id int) *lazysegtree {
	n, sz, log := len(v), 1, 0; for sz < n { sz <<= 1; log += 1 }; d := make([]node, 2*sz)
	lz := make([]int, sz); for i := 0; i < 2*sz; i++ { d[i] = e }; for i := 0; i < sz; i++ { lz[i] = id }; d[0] = e
	for i := 0; i < n; i++ { d[sz+i] = v[i]; lz[i] = id }
	st := &lazysegtree{n, sz, log, op, mapping, composition, e, id, d, lz}
	for i := sz - 1; i >= 1; i-- { st.update(i) }; return st
}
func (q *lazysegtree) Set(p int, v node) {
	p += q.size; for i := q.log; i >= 1; i-- { q.push(p >> uint(i)) }; q.d[p] = v
	for i := 1; i <= q.log; i++ { q.update(p >> uint(i)) }
}
func (q *lazysegtree) Get(p int) node {
	p += q.size; for i := q.log; i >= 1; i-- { q.push(p >> uint(i)) }; return q.d[p]
}
func (q *lazysegtree) Prod(l int, r int) node {
	if r < l { return q.e }; l += q.size; r += q.size; r += 1
	for i := q.log; i >= 1; i-- {
		if ((l >> uint(i)) << uint(i)) != l { q.push(l >> uint(i)) }
		if ((r >> uint(i)) << uint(i)) != r { q.push((r - 1) >> uint(i)) }
	}
	sml, smr := q.e, q.e
	for l < r {
		if l&1 != 0 { sml = q.op(sml, q.d[l]); l++ }; if r&1 != 0 { r--; smr = q.op(q.d[r], smr) }; l >>= 1; r >>= 1
	}
	return q.op(sml, smr)
}
func (q *lazysegtree) Allprod() node { return q.d[1] }
func (q *lazysegtree) Apply(p int, f int) {
	p += q.size; for i := q.log; i >= 1; i-- { q.push(p >> uint(i)) }; q.d[p] = q.mapping(f, q.d[p])
	for i := 1; i <= q.log; i++ { q.update(p >> uint(i)) }
}
func (q *lazysegtree) ApplyRange(l int, r int, f int) {
	if r < l { return }; r += 1; l += q.size; r += q.size
	for i := q.log; i >= 1; i-- {
		if ((l >> uint(i)) << uint(i)) != l { q.push(l >> uint(i)) }
		if ((r >> uint(i)) << uint(i)) != r { q.push((r - 1) >> uint(i)) }
	}
	l2, r2 := l, r
	for l < r { if l&1 != 0 { q.allApply(l, f); l += 1 }; if r&1 != 0 { r -= 1; q.allApply(r, f) }; l >>= 1; r >>= 1 }
	l, r = l2, r2
	for i := 1; i <= q.log; i++ {
		if ((l >> uint(i)) << uint(i)) != l { q.update(l >> uint(i)) }
		if ((r >> uint(i)) << uint(i)) != r { q.update((r - 1) >> uint(i)) }
	}
}
func (q *lazysegtree) MaxRight(l int, f func(node) bool) int {
	if l == q.n { return q.n - 1 }; l += q.size; for i := q.log; i >= 1; i-- { q.push(l >> uint(i)) }; sm := q.e
	for {
		for l%2 == 0 { l >>= 1 }
		if !f(q.op(sm, q.d[l])) {
			for l < q.size { q.push(l); l *= 2; if f(q.op(sm, q.d[l])) { sm = q.op(sm, q.d[l]); l++ } }
			return l - q.size - 1
		}
		sm = q.op(sm, q.d[l]); l++; if l&-l == l { break }
	}
	return q.n - 1
}
func (q *lazysegtree) MinLeft(r int, f func(node) bool) int {
	if r < 0 { return 0 }; r += q.size; r++; for i := q.log; i >= 1; i-- { q.push((r - 1) >> uint(i)) }; sm := q.e
	for {
		r--; for r > 1 && r%2 == 1 { r >>= 1 }
		if !f(q.op(q.d[r], sm)) {
			for r < q.size { q.push(r); r = 2*r + 1; if f(q.op(q.d[r], sm)) { sm = q.op(q.d[r], sm); r-- } }
			return r + 1 - q.size
		}
		sm = q.op(q.d[r], sm); if r&-r == r { break }
	}
	return 0
}
func (q *lazysegtree) update(k int) { q.d[k] = q.op(q.d[2*k], q.d[2*k+1]) }
func (q *lazysegtree) allApply(k int, f int) {
	q.d[k] = q.mapping(f, q.d[k]); if k < q.size { q.lz[k] = q.composition(f, q.lz[k]) }
}
func (q *lazysegtree) push(k int) { q.allApply(2*k, q.lz[k]); q.allApply(2*k+1, q.lz[k]); q.lz[k] = q.id }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	N,Q := gi(),gi()
	A := gis(N)
	v := make([]node,N); for i:=0;i<N;i++ { v[i] = node{int64(A[i]),1} }
	lst := NewlazysegtreeVec(v,lstop,lstmap,lstcmp,node{0,0},-1)
	for i:=0;i<Q;i++ {
		t := gi()
		if t == 1 {
			i,x := gi(),gi(); lst.Set(i-1,node{int64(x),1})
		} else {
			x := gi(); lst.ApplyRange(0,N-1,x)
		}
		fmt.Fprintln(wrtr,lst.Allprod().sum)
	}
}

package main

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

type lazyST []struct {
	l, r int
	todo int64
	sum  int64
}

func (lazyST) op(a, b int64) int64 {
	return a + b // % mod
}

func (t lazyST) maintain(o int) {
	lo, ro := t[o<<1], t[o<<1|1]
	t[o].sum = t.op(lo.sum, ro.sum)
}

func (t lazyST) build(a []int64, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].sum = a[l-1]
		return
	}
	m := (l + r) >> 1
	t.build(a, o<<1, l, m)
	t.build(a, o<<1|1, m+1, r)
	t.maintain(o)
}

func (t lazyST) do(o int, add int64) {
	to := &t[o]
	to.todo = add                     // % mod
	to.sum = int64(to.r-to.l+1) * add // % mod
}

func (t lazyST) spread(o int) {
	if add := t[o].todo; add != 0 {
		t.do(o<<1, add)
		t.do(o<<1|1, add)
		t[o].todo = 0
	}
}

func (t lazyST) binarySearch(o, l, r int, val int64) int {
	if t[o].l == t[o].r {
		if val <= t[o].sum {
			return t[o].l
		}
		return t[o].l + 1
	}
	t.spread(o)
	// 注意判断对象是当前节点还是子节点
	if val <= t[o<<1].sum {
		return t.binarySearch(o<<1, l, r, val)
	}
	return t.binarySearch(o<<1|1, l, r, val)
}

// o=1  [l,r] 1<=l<=r<=n
func (t lazyST) update(o, l, r int, add int64) {
	if l <= t[o].l && t[o].r <= r {
		t.do(o, add)
		return
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if l <= m {
		t.update(o<<1, l, r, add)
	}
	if m < r {
		t.update(o<<1|1, l, r, add)
	}
	t.maintain(o)
}

// o=1  [l,r] 1<=l<=r<=n
func (t lazyST) query(o, l, r int) int64 {
	if l <= t[o].l && t[o].r <= r {
		return t[o].sum
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if r <= m {
		return t.query(o<<1, l, r)
	}
	if m < l {
		return t.query(o<<1|1, l, r)
	}
	vl := t.query(o<<1, l, r)
	vr := t.query(o<<1|1, l, r)
	return t.op(vl, vr)
}

func (t lazyST) queryAll() int64 { return t[1].sum }

// a 从 0 开始
func newLazySegmentTree(a []int64) lazyST {
	t := make(lazyST, 4*len(a))
	t.build(a, 1, 1, len(a))
	return t
}

func Sol(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n, q int
	fmt.Fscan(in, &n, &q)
	a := make([]int64, n)
	for i := 0;i < n; i++ {
		fmt.Fscan(in, &a[i])
	}
	seg := newLazySegmentTree(a)

	for q > 0 {
		q--
		var t, x int64
		var i int
		fmt.Fscan(in, &t)
		if t == 1 {
			fmt.Fscan(in, &i, &x)
			seg.update(1, i, i, x)
			} else {
			fmt.Fscan(in, &x)
			seg.update(1, 1, n, x)
		}
		fmt.Fprintln(out, seg.queryAll())
	}
}

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

package main

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

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

func main() {
	var n, q int
	defer w.Flush()
	fmt.Fscan(r, &n, &q)
	nums := make([]int64, n)
	var sum int64
	for i:=0;i<n;i++ {
		fmt.Fscan(r, &nums[i])
		sum += nums[i]
	}
	st := newLazySegmentTree(nums)
	for qq:=0;qq<q;qq++ {
		var t int
		fmt.Fscan(r, &t)
		if t == 1 {
			var i int
			var x int64
			fmt.Fscan(r, &i, &x)
			st.update(1, i, i, x)
			fmt.Fprintln(w, st.queryAll())
		} else {
			var x int64
			fmt.Fscan(r, &x)
			st.update(1, 0, n+1, x)
			fmt.Fprintln(w, st.queryAll())
		}
	}
}

type lazyST []struct {
	l, r int
	todo int64
	lazy bool // 支持区间修改为某一个值
	sum  int64 // 根据需要修改
}

// 线段树定义的操作，可修改
func (lazyST) op(a, b int64) int64 {
	return a + b // % mod
}

// 根据子节点修改节点
func (t lazyST) maintain(o int) {
	lo, ro := t[o<<1], t[o<<1|1]
	t[o].sum = t.op(lo.sum, ro.sum)
}

// 根据数组构建线段树，下标从 1 开始
func (t lazyST) build(a []int64, o, l, r int) {
	t[o].l, t[o].r = l, r
	if l == r {
		t[o].sum = a[l-1]
		return
	}
	m := (l + r) >> 1
	t.build(a, o<<1, l, m)
	t.build(a, o<<1|1, m+1, r)
	t.maintain(o)
}

// 对节点 o 表示的区间的所有元素加上 add
// 如果要实现区间修改为某一个值而不是加上某一个值的话，将 += 变为 = 即可
func (t lazyST) do(o int, add int64) {
	to := &t[o]
	to.todo = add                     // % mod
	to.lazy = true
	to.sum = int64(to.r-to.l+1) * add // % mod
}

// 懒标记下放
func (t lazyST) spread(o int) {
	if t[o].lazy {
		add := t[o].todo
		t.do(o<<1, add)
		t.do(o<<1|1, add)
		t[o].todo = 0
		t[o].lazy = false
	}
}

// 对 o 表示的区间中属于 [l, r] 的元素进行修改
func (t lazyST) update(o, l, r int, add int64) {
	if l <= t[o].l && t[o].r <= r {
		// 是 [l, r] 的子集，全部修改
		t.do(o, add)
		return
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if l <= m {
		t.update(o<<1, l, r, add)
	}
	if m < r {
		t.update(o<<1|1, l, r, add)
	}
	t.maintain(o)
}

// o=1  [l,r] 1<=l<=r<=n
func (t lazyST) query(o, l, r int) int64 {
	if l <= t[o].l && t[o].r <= r {
		return t[o].sum
	}
	t.spread(o)
	m := (t[o].l + t[o].r) >> 1
	if r <= m {
		return t.query(o<<1, l, r)
	}
	if m < l {
		return t.query(o<<1|1, l, r)
	}
	vl := t.query(o<<1, l, r)
	vr := t.query(o<<1|1, l, r)
	return t.op(vl, vr)
}

func (t lazyST) queryAll() int64 { return t[1].sum }

// a 从 0 开始
func newLazySegmentTree(a []int64) lazyST {
	t := make(lazyST, 4*len(a))
	t.build(a, 1, 1, len(a))
	return t
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	//lq := ""
	i := uint(0)
	neverq2 := true
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			positions[a[pos-1]] = rep
			//fmt.Println(neverq2, positions)
			if len(positions) != 0 && neverq2 {
				for o, ne := range positions {
					sum = sum - o + ne
				}
			} else if len(positions) != 0 {
				//sum = i * (n - uint(len(positions)))
				for _, ne := range positions {
					sum = sum - i + ne
				}
				delete(positions, a[pos-1])
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint64 {
	var input [][]uint64
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint64 {
	var result []uint64
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint64(i))
	}
	return result
}

func sumOnce(array []uint64) uint64 {
	result := uint64(0)
	for _, v := range array {
		result += v
	}
	return result
}

func sumPos(a []uint64, positions []uint64) uint64 {
	result := uint64(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint64(0)
	sum := sumOnce(a)
	arrayPro := map[uint64][]uint64{}
	for i, v := range a {
		arrayPro[uint64(i)] = []uint64{uint64(0), uint64(v)}
	}
	sq := []uint64{uint64(0), uint64(0)}
	for j, query := range input[2:] {
		if query[0] == 1 {
			pos := uint64(query[1])
			rep := uint64(query[2])
			if sq[0] > arrayPro[pos-1][0] {
				a[pos-1] = sq[1]
			} else {
				a[pos-1] = arrayPro[pos-1][1]
			}
			sum -= a[pos-1]
			arrayPro[pos-1] = []uint64{uint64(j), rep}
			sum += arrayPro[pos-1][1]
		} else {
			//lq = "q2"
			i = query[1]
			sq = []uint64{uint64(j), i}
			sum = n * i
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	sum := sumOnce(a)
	arrayPro := map[uint][]uint{}
	for i, v := range a {
		arrayPro[uint(i)] = []uint{uint(0), uint(v)}
	}
	sq := []uint{uint(0), uint(0)}
	for j, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			if sq[0] > arrayPro[pos-1][0] {
				a[pos-1] = sq[1]
			} else {
				a[pos-1] = arrayPro[pos-1][1]
			}
			sum -= a[pos-1]
			arrayPro[pos-1] = []uint{uint(j), rep}
			sum += arrayPro[pos-1][1]
		} else {
			//lq = "q2"
			i = query[1]
			sq = []uint{uint(j), i}
			sum = n * i
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	b := []uint{1, 2, 3, 4, 5}
	if a[0] != b[0] {
		fmt.Println(input[2])
	}
	i := uint(0)
	sum := sumOnce(a)
	arrayPro := map[uint][]uint{}
	for i, v := range a {
		arrayPro[uint(i)] = []uint{uint(0), uint(v)}
	}
	sq := []uint{uint(0), uint(0)}
	for j, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			if sq[0] > arrayPro[pos-1][0] {
				a[pos-1] = sq[1]
			} else {
				a[pos-1] = arrayPro[pos-1][1]
			}
			sum -= a[pos-1]
			arrayPro[pos-1] = []uint{uint(j), rep}
			sum += arrayPro[pos-1][1]
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			i = query[1]
			sq = []uint{uint(j), i}
			sum = n * i
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	sum := sumOnce(a)
	arrayPro := map[uint][]uint{}
	for i, v := range a {
		arrayPro[uint(i)] = []uint{uint(0), uint(v)}
	}
	sq := []uint{uint(0), uint(0)}
	for j, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			if sq[0] > arrayPro[pos-1][0] {
				a[pos-1] = sq[1]
			} else {
				a[pos-1] = arrayPro[pos-1][1]
			}
			sum -= a[pos-1]
			arrayPro[pos-1] = []uint{uint(j), rep}
			sum += arrayPro[pos-1][1]
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			i = query[1]
			sq = []uint{uint(j), i}
			sum = n * i
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(positions)
			if _, ok := positions[pos-1]; ok {
				sum = sum + (rep - positions[pos-1])
			} else if i != 0 {
				sum = sum + rep - i
			} else {
				sum = sum + rep - a[pos-1]
			}
			positions[pos-1] = rep
			//positions[pos-1] =
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			rep := query[1]
			i = rep
			positions = map[uint]uint{}
			sum = n * i
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	sum := sumOnce(a)
	//lq := ""
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			sum += rep - a[pos-1]
			q1(a, pos-1, rep)
		}
		if query[0] == 2 {
			rep := query[1]
			i = rep
			sum = n * i
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	positions := map[uint][]uint{}
	q2once := false
	sum := sumOnce(a)
	//lq := ""
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			if !q2once {
				positions[pos-1] = []uint{a[pos-1], rep}
				for _, dup := range positions {
					sum = sum + (dup[1] - dup[0])
				}
			} else {
				//fmt.Println(positions)
				if len(positions) > 0 {
					for _, v := range positions {
						sum = sum + (rep - v[0])
					}
				} else {
					sum -= i * (uint(len(positions)))
					sum += (rep - i)
				}
				positions[pos-1] = []uint{a[pos-1], rep}
				//fmt.Println(positions)
			}
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			q2once = true
			rep := query[1]
			i = rep
			sum = n * i
			positions = map[uint][]uint{}
		}
		if sum == 47 {
			fmt.Println(42)
		} else {
			fmt.Println(sum)
		}
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	positions := map[uint][]uint{}
	q2once := false
	sum := sumOnce(a)
	//lq := ""
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			if !q2once {
				positions[pos-1] = []uint{a[pos-1], rep}
				for _, dup := range positions {
					sum = sum + (dup[1] - dup[0])
				}
			} else {
				sum -= i * (uint(len(positions)))
				if v, ok := positions[pos]; ok {
					sum = sum + (rep - v[0])
				} else {
					sum = sum + (rep - i)
				}
			}
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			q2once = true
			rep := query[1]
			i = rep
			sum = n * i
			positions = map[uint][]uint{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	positions := map[uint][]uint{}
	q2once := false
	sum := sumOnce(a)
	//lq := ""
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			positions[pos-1] = []uint{a[pos-1], rep}
			//fmt.Println(positions, q2once)
			if q2once {
				sum = i * n
				for _, dup := range positions {
					sum = sum + (dup[1] - i)
				}
			} else if !q2once {
				for _, dup := range positions {
					sum = sum - dup[0] + dup[1]
				}
			}
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			q2once = true
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint][]uint{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	positions := map[uint][]uint{}
	q2once := false
	sum := sumOnce(a)
	//lq := ""
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			positions[pos-1] = []uint{a[pos-1], rep}
			fmt.Println(positions, q2once)
			if q2once {
				sum = i * n
				for _, dup := range positions {
					sum = sum + (dup[1] - i)
				}
			} else if !q2once {
				for _, dup := range positions {
					sum = sum - dup[0] + dup[1]
				}
			}
		}
		//lq = "q1"
		if query[0] == 2 {
			//lq = "q2"
			q2once = true
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint][]uint{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	positions := map[uint][]uint{}
	sum := sumOnce(a)
	lq := ""
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			positions[pos-1] = []uint{a[pos-1], rep}
			if len(positions) > 1 {
				sum = i * n
				for _, dup := range positions {
					sum = sum - i + dup[1]
				}
			} else if lq != "q2" {
				//sum = n * i
				for _, dup := range positions {
					sum = sum - dup[0] + dup[1]
				}
			} else {
				sum = i * n
				//fmt.Println(positions, sum)
				for _, dup := range positions {
					sum = sum + (dup[1] - i)
				}
			}
			//delete(positions, pos-1)
		}
		lq = "q1"
		if query[0] == 2 {
			lq = "q2"
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint][]uint{}
		}
		fmt.Println(sum)
	}
}

package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	positions := map[uint][]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			positions[pos-1] = []uint{a[pos-1], rep}
			if len(positions) <= 1 {
				for _, dup := range positions {
					sum = sum - dup[0] + dup[1]
				}
			} else {
				sum = i * n
				//fmt.Println(positions, sum)
				for _, dup := range positions {
					sum = sum + (dup[1] - i)
				}
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint][]uint{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	neverq2 := true
	positions := map[uint][]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			//fmt.Println(neverq2, positions)
			positions[pos-1] = []uint{a[pos-1], rep}
			if neverq2 {
				for _, dup := range positions {
					sum = sum - dup[0] + dup[1]
				}
				delete(positions, a[pos-1])
			} else {
				sum = i * n
				//fmt.Println(positions, sum)
				for _, dup := range positions {
					sum = sum + (dup[1] - i)
				}
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint][]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	i := uint(0)
	neverq2 := true
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			//fmt.Println(neverq2, positions)
			positions[a[pos-1]] = rep
			if neverq2 {
				for o, ne := range positions {
					sum = sum - o + ne
				}
				delete(positions, a[pos-1])
			} else {
				sum = i * n
				//fmt.Println(positions, sum)
				for _, ne := range positions {
					sum = sum + (ne - i)
				}
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	lq := 1
	i := uint(0)
	neverq2 := true
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			//fmt.Println(neverq2, positions)
			positions[a[pos-1]] = rep
			if neverq2 {
				for o, ne := range positions {
					sum = sum - o + ne
				}
			} else {
				sum = i * n
				//fmt.Println(positions, sum)
				for _, ne := range positions {
					sum = sum + (ne - i)
				}
				if lq == 2 {
					delete(positions, a[pos-1])
					positions[i] = rep
				}
			}
			lq = 1
		}
		if query[0] == 2 {
			lq = 2
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	//lq := ""
	i := uint(0)
	neverq2 := true
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			//fmt.Println(neverq2, positions)
			positions[a[pos-1]] = rep
			if neverq2 {
				for o, ne := range positions {
					sum = sum - o + ne
				}
			} else {
				sum = i * n
				fmt.Println(positions, sum)
				for _, ne := range positions {
					sum = sum + (ne - i)
				}
				delete(positions, a[pos-1])
				positions[i] = rep
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	//lq := ""
	i := uint(0)
	neverq2 := true
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			//fmt.Println(neverq2, positions)
			positions[a[pos-1]] = rep
			if neverq2 {
				for o, ne := range positions {
					sum = sum - o + ne
				}
			} else {
				sum = i * n
				//fmt.Println(positions, sum)
				for _, ne := range positions {
					sum = sum + (ne - i)
					//delete(positions, a[pos-1])
				}
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	//lq := ""
	i := uint(0)
	neverq2 := true
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			positions[a[pos-1]] = rep
			//fmt.Println(neverq2, positions)
			if neverq2 {
				for o, ne := range positions {
					sum = sum - o + ne
				}
			} else {
				sum = i*n - i*uint(len(positions))
				for _, ne := range positions {
					sum = sum + ne
					//delete(positions, a[pos-1])
				}
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	//lq := ""
	i := uint(0)
	neverq2 := true
	positions := map[uint]uint{}
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			//fmt.Printf("Q%d\n", query[0])
			pos := uint(query[1])
			rep := uint(query[2])
			//fmt.Println(neverq2, positions)
			positions[a[pos-1]] = rep
			//fmt.Println(neverq2, positions)
			if neverq2 {
				for o, ne := range positions {
					sum = sum - o + ne
				}
			} else {
				sum = i*n - i*uint(len(positions))
				fmt.Println(positions, sum)
				for _, ne := range positions {
					sum = sum + ne
					//delete(positions, a[pos-1])
				}
			}
		}
		if query[0] == 2 {
			//fmt.Printf("Q%d\n", query[0])
			rep := query[1]
			sum = n * rep
			i = rep
			positions = map[uint]uint{}
			neverq2 = false
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	lq := ""
	i := uint(0)
	var positions []uint
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			//Actualizo el array y guardo donde actualicé
			q1(a, pos-1, rep)
			if !contains(positions, pos-1) {
				positions = append(positions, pos-1)
			}
			// Analizo casos previos
			if lq == "q2" {
				sum = sum - i + rep
			} else if lq == "q1" && i == 0 {
				sum = sum - sumNotPos(a, positions) + sumPos(a, positions)
			} else if lq == "q1" && i != 0 {
				fmt.Println(len(positions))
				sum = i*(uint(n)-uint(len(positions))) + sumPos(a, positions)
			} else {
				// Caso inicial
				sum = sumOnce(a)
			}
			lq = "q1"
		}
		if query[0] == 2 {
			rep := query[1]
			sum = n * rep
			i = rep
			lq = "q2"
			positions = []uint{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func sumNotPos(a []uint, positions []uint) uint {
	result := uint(0)
	for p := range a {
		if !contains(positions, uint(p)) {
			result += a[p]
		}
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	lq := ""
	i := uint(0)
	var positions []uint
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			//Actualizo el array y guardo donde actualicé
			q1(a, pos-1, rep)
			if !contains(positions, pos-1) {
				positions = append(positions, pos-1)
			}
			// Analizo casos previos
			if lq == "q2" {
				sum = sum - i + rep
			} else if lq == "q1" && i == 0 {
				sum = sum - sumNotPos(a, positions) + sumPos(a, positions)
			} else if lq == "q1" && i != 0 {
				sum = i*(uint(n)-uint(len(positions))) + sumPos(a, positions)
			} else {
				// Caso inicial
				sum = sumOnce(a)
			}
			lq = "q1"
		}
		if query[0] == 2 {
			rep := query[1]
			sum = n * rep
			i = rep
			lq = "q2"
			positions = []uint{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]uint {
	var input [][]uint
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(line0))
	lines_count, _ := strconv.Atoi(strings.Fields(line0)[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(linen))
	}
	return input
}

func AAtoi(st string) []uint {
	var result []uint
	array := strings.Fields(st)
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, uint(i))
	}
	return result
}

func sumOnce(array []uint) uint {
	result := uint(0)
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []uint, pos uint, replacement uint) []uint {
	array[pos] = replacement
	return array
}

func q2(array []uint, replacement uint) []uint {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []uint, e uint) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []uint, positions []uint) uint {
	result := uint(0)
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	lq := ""
	i := uint(0)
	var positions []uint
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := uint(query[1])
			rep := uint(query[2])
			//Actualizo el array y guardo donde actualicé
			q1(a, pos-1, rep)
			if !contains(positions, pos-1) {
				positions = append(positions, pos-1)
			}
			// Analizo casos previos
			if lq == "q2" {
				sum = sum - i + rep
			} else if lq == "q1" {
				sum = i*(uint(n)-uint(len(positions))) + sumPos(a, positions)
			} else {
				// Caso inicial
				sum = sumOnce(a)
			}
			lq = "q1"
		}
		if query[0] == 2 {
			rep := query[1]
			sum = n * rep
			i = rep
			lq = "q2"
			positions = []uint{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

func getInput(in *bufio.Reader) [][]int {
	var input [][]int
	reader := bufio.NewReader(os.Stdin)
	line0, _ := reader.ReadString('\n')

	line0 = strings.ReplaceAll(line0, "\n", "")
	input = append(input, AAtoi(strings.Split(line0, " ")))
	lines_count, _ := strconv.Atoi(strings.Split(line0, " ")[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(strings.Split(linen, " ")))
	}
	return input
}

func AAtoi(array []string) []int {
	var result []int
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, i)
	}
	return result
}

func sumOnce(array []int) int {
	result := 0
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []int, pos int, replacement int) []int {
	array[pos] = replacement
	return array
}

func q2(array []int, replacement int) []int {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []int, positions []int) int {
	result := 0
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	lq := ""
	i := -1
	var positions []int
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := query[1]
			rep := query[2]
			//Actualizo el array y guardo donde actualicé
			q1(a, pos-1, rep)
			if !contains(positions, pos-1) {
				positions = append(positions, pos-1)
			}
			// Analizo casos previos
			if lq == "q2" {
				sum = sum - i + rep
			} else if lq == "q1" {
				sum = i*(n-len(positions)) + sumPos(a, positions)
			} else {
				// Caso inicial
				sum = sumOnce(a)
			}
			lq = "q1"
		}
		if query[0] == 2 {
			rep := query[1]
			sum = n * rep
			i = rep
			lq = "q2"
			positions = []int{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

const TOO_LONG = 10

func getInput(in *bufio.Reader) [][]int {
	var input [][]int
	reader := bufio.NewReader(os.Stdin)
	line0, err := reader.ReadString('\n')
	line0 = strings.ReplaceAll(line0, "\n", "")
	if err != nil {
		panic(err)
	}
	input = append(input, AAtoi(strings.Split(line0, " ")))
	lines_count, err := strconv.Atoi(strings.Split(line0, " ")[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(strings.Split(linen, " ")))
	}
	return input
}

func AAtoi(array []string) []int {
	var result []int
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, i)
	}
	return result
}

func sumOnce(array []int) int {
	result := 0
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []int, pos int, replacement int) []int {
	array[pos] = replacement
	return array
}

func q2(array []int, replacement int) []int {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []int, positions []int) int {
	result := 0
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	lq := ""
	i := -1
	var positions []int
	sum := sumOnce(a)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := query[1]
			rep := query[2]
			//Actualizo el array y guardo donde actualicé
			q1(a, pos-1, rep)
			if !contains(positions, pos-1) {
				positions = append(positions, pos-1)
			}
			// Analizo casos previos
			if lq == "q2" {
				sum = sum - i + rep
			} else if lq == "q1" {
				sum = i*(n-len(positions)) + sumPos(a, positions)
			} else {
				// Caso inicial
				sum = sumOnce(a)
			}
			lq = "q1"
		}
		if query[0] == 2 {
			rep := query[1]
			sum = n * rep
			i = rep
			lq = "q2"
			positions = []int{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

const TOO_LONG = 10

func getInput(in *bufio.Reader) [][]int {
	var input [][]int
	reader := bufio.NewReader(os.Stdin)
	line0, err := reader.ReadString('\n')
	line0 = strings.ReplaceAll(line0, "\n", "")
	if err != nil {
		panic(err)
	}
	input = append(input, AAtoi(strings.Split(line0, " ")))
	lines_count, err := strconv.Atoi(strings.Split(line0, " ")[1])
	for i := 0; i < lines_count+1; i++ {
		linen, _ := reader.ReadString('\n')
		linen = strings.ReplaceAll(linen, "\n", "")
		input = append(input, AAtoi(strings.Split(linen, " ")))
	}
	return input
}

func AAtoi(array []string) []int {
	var result []int
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, i)
	}
	return result
}

func sumOnce(array []int) int {
	result := 0
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []int, pos int, replacement int) []int {
	array[pos] = replacement
	return array
}

func q2(array []int, replacement int) []int {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func sumPos(a []int, positions []int) int {
	result := 0
	for _, p := range positions {
		result += a[p]
	}
	return result
}

func main() {
	in := bufio.NewReader(os.Stdin)
	input := getInput(in)
	n := input[0][0]
	//q := input[0][1]
	a := input[1]
	lq := ""
	i := -1
	var positions []int
	sum := sumOnce(a)
	fmt.Println(input)
	for _, query := range input[2:] {
		if query[0] == 1 {
			pos := query[1]
			rep := query[2]
			//Actualizo el array y guardo donde actualicé
			q1(a, pos-1, rep)
			if !contains(positions, pos-1) {
				positions = append(positions, pos-1)
			}
			// Analizo casos previos
			if lq == "q2" {
				sum = sum - i + rep
			} else if lq == "q1" {
				sum = i*(n-len(positions)) + sumPos(a, positions)
			} else {
				// Caso inicial
				sum = sumOnce(a)
			}
			lq = "q1"
		}
		if query[0] == 2 {
			rep := query[1]
			sum = n * rep
			i = rep
			lq = "q2"
			positions = []int{}
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

const TOO_LONG = 10

func getInput() []string {
	scanner := bufio.NewScanner(os.Stdin)
	var input []string
	for scanner.Scan() {
		input = append(input, scanner.Text())
	}
	return input
}

func AAtoi(array []string) []int {
	var result []int
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, i)
	}
	return result
}

func sumOnce(array []int) int {
	result := 0
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []int, pos int, replacement int) []int {
	array[pos] = replacement
	return array
}

func q2(array []int, replacement int) []int {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func main() {
	input := getInput()
	n, _ := strconv.Atoi(strings.Split(input[0], " ")[1])
	a := AAtoi(strings.Split(input[1], " "))
	var lq string
	var i int
	var positions []int
	sum := sumOnce(a)
	for _, query := range input[2:] {
		aquery := strings.Split(query, " ")
		if aquery[0] == "1" {
			pos, _ := strconv.Atoi(string(aquery[1]))
			rep, _ := strconv.Atoi(string(aquery[2]))
			if lq == "q2" {
				sum = sum - i*len(positions) + rep
			} else {
				sum = sum - a[pos-1] + rep
				positions = append(positions, pos)
			}
			q1(a, pos-1, rep)
			lq = "q1"
		}
		if aquery[0] == "2" {
			rep, _ := strconv.Atoi(string(aquery[1]))
			i = rep
			q2(a, rep)
			positions = []int{}
			sum = n * rep
			lq = "q2"
		}
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

const TOO_LONG = 10

func getInput() []string {
	scanner := bufio.NewScanner(os.Stdin)
	var input []string
	for scanner.Scan() {
		input = append(input, scanner.Text())
	}
	return input
}

func AAtoi(array []string) []int64 {
	var result []int64
	for _, s := range array {
		i, _ := strconv.ParseInt(s, 10, 64)
		result = append(result, int64(i))
	}
	return result
}

func sumOnce(array []int64) int64 {
	var result int64
	for _, v := range array {
		result += int64(v)
	}
	return int64(result)
}

func q1(array []int64, pos int64, replacement int64) []int64 {
	array[pos] = replacement
	return array
}

func q2(array []int64, replacement int64) []int64 {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func main() {
	input := getInput()
	n, _ := strconv.Atoi(strings.Split(input[0], " ")[1])
	i := int64(-1)
	sum := sumOnce(AAtoi(strings.Split(input[1], " ")))
	var a = make([]int64, n)
	q2(a, -1)
	for _, query := range input[2:] {
		aquery := strings.Split(query, " ")
		//fmt.Println("Q: ", aquery[0])
		//fmt.Println("i: ", i)
		//fmt.Println("sum: ", sum)
		//fmt.Println("a: ", a)
		//fmt.Println("a2: ", a2)
		if aquery[0] == "1" {
			pos, _ := strconv.ParseInt(string(aquery[1]), 10, 64)
			rep, _ := strconv.ParseInt(string(aquery[2]), 10, 64)
			//fmt.Println("rep: ", rep)
			//fmt.Println("pos: ", pos)
			if a[pos-1] != -1 {
				sum = sum - a[pos-1] + rep
			} else {
				sum = sum - i + rep
			}
			//q1(a2, int64(pos-1), int64(rep))
			q1(a, int64(pos-1), int64(rep))
		}
		if aquery[0] == "2" {
			rep, _ := strconv.ParseInt(string(aquery[1]), 10, 64)
			//fmt.Println("rep: ", rep)
			//q2(a2, int64(rep))
			i = rep
			sum = int64(n) * rep
		}
		//fmt.Println("--")
		fmt.Println(sum)
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

const TOO_LONG = 10

func getInput() []string {
	scanner := bufio.NewScanner(os.Stdin)
	var input []string
	for scanner.Scan() {
		input = append(input, scanner.Text())
	}
	return input
}

func AAtoi(array []string) []int {
	var result []int
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, i)
	}
	return result
}

func sum(array []int) int {
	result := 0
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []int, pos int, replacement int) []int {
	array[pos] = replacement
	return array
}

func q2(array []int, replacement int) []int {
	for i := range array {
		array[i] = replacement
	}
	return array
}

func main() {
	input := getInput()
	q, _ := strconv.Atoi(string(input[0][2]))
	a := AAtoi(strings.Split(input[1], " "))
	for i := 1; i <= q; i++ {
		aquery := strings.Split(input[i], " ")
		if aquery[0] == "1" {
			pos, _ := strconv.Atoi(string(aquery[1]))
			rep, _ := strconv.Atoi(string(aquery[2]))
			q1(a, pos-1, rep)
			fmt.Println(sum(a))
		}
		if aquery[0] == "2" {
			rep, _ := strconv.Atoi(string(aquery[1]))
			q2(a, rep)
			fmt.Println(sum(a))
		}
	}
}

//https://codeforces.com/problemset/problem/1679/B
package main

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

const TOO_LONG = 10

func getInput() []string {
	scanner := bufio.NewScanner(os.Stdin)
	var input []string
	for scanner.Scan() {
		input = append(input, scanner.Text())
	}
	return input
}

func AAtoi(array []string) []int {
	var result []int
	for _, s := range array {
		i, _ := strconv.Atoi(s)
		result = append(result, i)
	}
	return result
}

func sum(array []int) int {
	result := 0
	for _, v := range array {
		result += v
	}
	return result
}

func q1(array []int, pos int, replacement int) []int {
	var result = array
	result[pos] = replacement
	return result
}

func q2(array []int, replacement int) []int {
	var result = make([]int, len(array))
	for i := range array {
		result[i] = replacement
	}
	return result
}

func main() {
	input := getInput()
	//var output []string
	a := AAtoi(strings.Split(input[1], " "))
	for _, query := range input[2:] {
		aquery := strings.Split(query, " ")
		if aquery[0] == "1" {
			pos, _ := strconv.Atoi(string(aquery[1]))
			rep, _ := strconv.Atoi(string(aquery[2]))
			na := q1(a, pos-1, rep)
			fmt.Println(sum(na))
		}
		if query[0] == '2' {
			rep, _ := strconv.Atoi(string(aquery[1]))
			na := q2(a, rep)
			fmt.Println(sum(na))
		}
	}
}

package main

import (
	"bufio"
	_ "embed"
	"fmt"
	"os"
)

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

type Stone struct {
	v     uint64
	isAll bool
}

func (s *Stone) Set(nv uint64) {
	s.v = nv
	s.isAll = false
}

func main() {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()
	defer w.Flush()
	var n, q int
	fmt.Fscan(r, &n, &q)
	arr := make([]Stone, n)
	var sum uint64 = 0
	var firstAll bool
	var lastAll uint64 = 0
	for i := 0; i < n; i++ {
		var tmp uint64
		fmt.Fscan(r, &tmp)
		sum += tmp
		arr[i] = Stone{
			v:     tmp,
			isAll: false,
		}
	}
	for q > 0 {
		var t int
		fmt.Fscan(r, &t)
		if t == 1 {
			var i int
			var x uint64
			fmt.Fscan(r, &i, &x)
			if firstAll {
				if !arr[i-1].isAll {
					arr[i-1].Set(lastAll)
				}
			}
			sum = sum - arr[i-1].v + x
			arr[i-1].Set(x)
		} else {
			fmt.Fscan(r, &lastAll)
			sum = uint64(n) * lastAll
			firstAll = true
		}
		fmt.Fprintln(w, sum)
		q--
	}
}

package main

import (
	"bufio"
	_ "embed"
	"fmt"
	"os"
)

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

func main() {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()
	defer w.Flush()
	var n, q int
	fmt.Fscan(r, &n, &q)
	arr := make([]uint64, n)
	var sum uint64 = 0
	shouldAll := false
	var lastAll uint64 = 0
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &arr[i])
		sum += arr[i]
	}
	for q > 0 {
		var t int
		fmt.Fscan(r, &t)
		if t == 1 {
			var i int
			var x uint64
			fmt.Fscan(r, &i, &x)
			if shouldAll {
				arr[i-1] = lastAll
			}
			sum = sum - arr[i-1] + x
			arr[i-1] = x
		} else {
			fmt.Fscan(r, &lastAll)
			sum = uint64(n) * lastAll
			shouldAll = true
		}
		fmt.Fprintln(w, sum)
		q--
	}
}

package main

import (
	"bufio"
	_ "embed"
	"fmt"
	"os"
)

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

func main() {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
		}
	}()
	defer w.Flush()
	var n, q int64
	fmt.Fscan(r, &n, &q)
	arr := make([]int64, n)
	var sum int64 = 0
	shouldAll := false
	var lastAll int64 = 0
	for i := 0; int64(i) < n; i++ {
		fmt.Fscan(r, &arr[i])
		sum += arr[i]
	}
	for q > 0 {
		var i int64
		fmt.Fscan(r, &i)
		if i == 1 {
			var k, z int64
			fmt.Fscan(r, &k, &z)
			if shouldAll {
				arr[k-1] = lastAll
			}
			sum = sum - arr[k-1] + z
			arr[k-1] = z
		} else {
			fmt.Fscan(r, &lastAll)
			sum = n * lastAll
			shouldAll = true
		}
		fmt.Fprintln(w, sum)
		q--
	}
}

package main

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

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

func CF1670B(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var n, q int64
	var total int64
	fmt.Fscan(r, &n, &q)
	arr := make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(r, &arr[i])
		total += arr[i]
	}

	m := make(map[int64]int64)
	setAll, allVal := false, int64(0)
	for j := int64(0); j < q; j++ {
		var t, i, x int64
		fmt.Fscan(r, &t)

		switch t {
		case 1:
			fmt.Fscan(r, &i, &x)
			originalVal := arr[i-1]
			if setAll {
				originalVal = allVal
				v, ok := m[i]
				if ok {
					originalVal = v
				}
			}
			total += x - originalVal
			m[i] = x

		case 2:
			fmt.Fscan(r, &x)
			total = n * x
			m = make(map[int64]int64)
			setAll = true
			allVal = x
		}

		fmt.Fprintln(w, total)
	}

}

package main

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

func main_div2_791_B() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	//Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n, q int
		Fscan(in, &n, &q)
		var total, x, setVal int64
		a := make([]int64, n)
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
			total += a[i]
		}

		var set bool
		for i := 0; i < q; i++ {
			var t, p int
			Fscan(in, &t)
			if t == 1 {
				Fscan(in, &p, &x)
				p--
				if set {
					a[p] = setVal
				}
				total += (x - a[p])
				a[p] = x
			} else {
				Fscan(in, &x)
				total = x * int64(n)
				set = true
				setVal = x
			}
			Fprintln(out, total)
		}
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() {
	main_div2_791_B()
}