← Home
```go
package main

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

var parent []int

// find implements the find operation of DSU with path compression.
// It returns the index of the next non-full vessel (or n+1 if all subsequent are full).
func find(i int) int {
	if parent[i] == i {
		return i
	}
	parent[i] = find(parent[i])
	return parent[i]
}

func main() {
	// Configure fast I/O
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	// Helper to read an integer
	readInt := func() int {
		scanner.Scan()
		val, _ := strconv.Atoi(scanner.Text())
		return val
	}

	// Helper to read an int64
	readInt64 := func() int64 {
		scanner.Scan()
		val, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		return val
	}

	// Read number of vessels
	if !scanner.Scan() {
		return
	}
	n, _ := strconv.Atoi(scanner.Text())

	// Initialize arrays
	// 1-based indexing, so size n+2 to handle n+1 (floor)
	parent = make([]int, n+2)
	capacity := make([]int64, n+2)
	current := make([]int64, n+2)

	for i := 1; i <= n; i++ {
		capacity[i] = readInt64()
		parent[i] = i
	}
	// n+1 represents the floor/end
	parent[n+1] = n + 1

	// Read number of queries
	m := readInt()

	for i := 0; i < m; i++ {
		t := readInt()
		if t == 1 {
			// Add water query
			p := readInt()
			x := readInt64()

			// Find the first non-full vessel starting from p
			curr := find(p)
			
			// Pour water until x runs out or we hit the floor
			for x > 0 && curr <= n {
				space := capacity[curr] - current[curr]
				if x >= space {
					// Fill the current vessel completely
					current[curr] = capacity[curr]
					x -= space
					
					// Mark this vessel as effectively skipped by pointing to the next one's root
					// find(curr+1) gets the next available vessel after curr
					parent[curr] = find(curr + 1)
					
					// Move to the next vessel
					curr = parent[curr]
				} else {
					// Add remaining water to current vessel and stop
					current[curr] += x
					x = 0
				}
			}
		} else {
			// Query water amount
			k := readInt()
			fmt.Fprintln(writer, current[k])
		}
	}
}
```