Problem:


Score : 200 points

Problem Statement

Joisino is about to compete in the final round of a certain programming competition.
In this contest, there are N problems, numbered 1 through N.
Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).

Also, there are M kinds of drinks offered to the contestants, numbered 1 through M.
If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.
It does not affect the time to solve the other problems.

A contestant is allowed to take exactly one of the drinks before the start of the contest.
For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.
Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.
Your task is to write a program to calculate it instead of her.

Constraints

All input values are integers.

1≦N≦100

1≦T_i≦10^5

1≦M≦100

1≦P_i≦N

1≦X_i≦10^5

Input

The input is given from Standard Input in the following format:

N
T_1 T_2 ... T_N
M
P_1 X_1
P_2 X_2
:
P_M X_M

Output

For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.

Sample Input 1

3
2 1 4
2
1 1
2 3

Sample Output 1

6
9

If Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.

If Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.

Sample Input 2

5
7 2 3 8 5
3
4 2
1 7
4 13

Sample Output 2

19
25
30



Sample input:
3
2 1 4
2
1 1
2 3


Sample output:
6
9

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

// Define
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <class T> using pvector = vector<pair<T, T>>;
template <class T>
using rpriority_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr const ll dx[4] = {1, 0, -1, 0};
constexpr const ll dy[4] = {0, 1, 0, -1};
constexpr const ll MOD = 1e9 + 7;
constexpr const ll mod = 998244353;
constexpr const ll INF = 1LL << 60;
constexpr const ll inf = 1 << 30;
constexpr const char rt = '\n';
constexpr const char sp = ' ';
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define elif else if
#define all(a, v, ...)                                                         \
    ([&](decltype((v)) w) { return (a)(begin(w), end(w), ##__VA_ARGS__); })(v)
#define rall(a, v, ...)                                                        \
    ([&](decltype((v)) w) { return (a)(rbegin(w), rend(w), ##__VA_ARGS__); })(v)
#define fi first
#define se second

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

// Debug
#define debug(...)                                                             \
    {                                                                          \
        cerr << __LINE__ << ": " << #__VA_ARGS__ << " = ";                     \
        for (auto &&X : {__VA_ARGS__}) cerr << "[" << X << "] ";               \
        cerr << rt;                                                            \
    }

#define dump(a, h, w)                                                          \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [" << rt;                        \
        rep(_i, h) {                                                           \
            rep(_j, w) cerr << a[_i][_j] << sp;                                \
            cerr << rt;                                                        \
        }                                                                      \
        cerr << "]" << rt;                                                     \
    }

#define vdump(a, n)                                                            \
    {                                                                          \
        cerr << __LINE__ << ": " << #a << " = [";                              \
        rep(_i, n) if (_i) cerr << sp << a[_i];                                \
        else cerr << a[_i];                                                    \
        cerr << "]" << rt;                                                     \
    }

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i <= _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i >= _##i; --i)
#define rep(i, n) for (ll i = 0, _##i = (n); i < _##i; ++i)
#define each(i, a) for (auto &&i : a)

// Stream
#define fout(n) cout << fixed << setprecision(n)
struct io {
    io() { cin.tie(nullptr), ios::sync_with_stdio(false); }
} io;

// Speed
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

// Math
inline constexpr ll gcd(const ll a, const ll b) {
    return b ? gcd(b, a % b) : a;
}
inline constexpr ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }

inline constexpr ll modulo(const ll n, const ll m = MOD) {
    ll k = n % m;
    return k + m * (k < 0);
}
inline constexpr ll chmod(ll &n, const ll m = MOD) {
    n %= m;
    return n += m * (n < 0);
}
inline constexpr ll mpow(ll a, ll n, const ll m = MOD) {
    ll r = 1;
    rep(i, 64) {
        if (n & (1LL << i)) r *= a;
        chmod(r, m);
        a *= a;
        chmod(a, m);
    }
    return r;
}
inline ll inv(const ll n, const ll m = MOD) {
    ll a = n, b = m, x = 1, y = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        x -= t * y;
        swap(x, y);
    }
    return modulo(x, m);
}

signed main() {
    ll N;
    cin >> N;
    ll A[N];
    rep(i, N) cin >> A[i];
    ll M, S = accumulate(A, A + N, 0LL);
    cin >> M;
    rep(i, M) {
        ll C, D;
        cin >> C >> D;
        cout << S - A[C - 1] + D << rt;
    }
}

// -g -D_GLIBCXX_DEBUG -fsanitize=undefined

Submission status: Runtime Error

Solution code:
N = int(input())
Tlist = [int(N) for N in input().split()]
M = int(input())
PXlist = [[int(i) for i in input().split()]for j in range(M)]
def time_sum():
    s = 0
    for i in range(0,N):
        s = s+Tlist[i]
    return s
def time_cal():
    empty = []
    for i in range(0,M):
        empty.append(time_sum() - Tlist[i] + PXlist[i][1])
    return empty
for i in time_cal():
    print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
Tlist = [int(N) for N in input().split()]
M = int(input())
PXlist = [[int(i) for i in input().split()]for j in range(M)]
def time_sum():
    s = 0
    for i in range(0,N):
        s = s+Tlist[i]
    return s
def time_cal():
    ans = ita.array.make1d(M)
    for i in range(0,M):
        ans[i] = time_sum() - Tlist[i] + PXlist[i][1]
    return ans
print(Tlist,PXlist)
time_cal()

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(map(int,input().split()))
sumt=sum(t)
m=int(input())

for i in range(m):
    px = [list(map(int, input().split())) for _ in range(m)]
    a=t[px[i][0]-1]
    b=px[i][1]
    print(sumt-a+b)

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(int(input().split()))
m=int(input())
px = [list(map(int, input().split())) for _ in range(m)]

for i in range(m):
    t[px[i][0]]=px[i][1]
    print(sum(t))

Submission status: Runtime Error

Solution code:
n = int(input()) 
t = list(map(int,input().strip().split()))[:n] 
m = int(input())
p=[]
x=[]
for _ in range(m):
    a,b = map(int,input().split())
    p.append(a)
    x.append(b)
s=sum(t)
for i in range(m):
    T=s
    T-=t[p[i]-1]
    T+=x[p[i]-1]
    print(T)

Submission status: Runtime Error

Solution code:
n = int(input()) 
t = list(map(int,input().strip().split()))[:n] 
m = int(input())
p=[]
x=[]
for _ in range(m):
    a,b = map(int,input().split())
    p.append(a)
    x.append(b)
s=sum(t)
for i in range(m):
    s-=t[p[i]-1]
    s+=x[p[i]-1]
    print(s)

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[list(map(int,input().split())) for _ in range(m)]

ans=sum(t)-t[0]-t[1]

for i in range(m):
    
    print(ans+sum(px[i]))

Submission status: Runtime Error

Solution code:
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
base_ = sum(Ts)

for m in range(1,M+1):
  p, t = map(int, input().split())
  print(base_ - (Ts[p]-t))

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(int(input().split()))
S = sum(T)
M = int(input())

for _ in range(M):
    p,x = map(int,input().split())
    ans = S - T[p-1] + x
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(int(input().split()))
S = sum(T)
M = int(input())

for _ in range(M):
    p,x = map(int,input().split())
    ans = S - T[] + x
    print(ans)

Submission status: Runtime Error

Solution code:
#ABC050.B
N = int(input())
T = int(input().split())
S = sum(T)
M = int(input())

for _ in range(M):
    p,x = map(int,input().split())
    ans = S - T[] + x[]
    print(ans)

Submission status: Runtime Error

Solution code:
#ABC050.B
N =int(input())
T = list(map(int,input().split()for _ in range(N)))
S = sum(T)
M = int(input())

for _ in range(M):
    a = S
    p,x = map(int,input().split())
    a -= T[p-1]
    a += x
    print(a)

Submission status: Runtime Error

Solution code:
#ABC050.B
N =int(input())
T = list(map(int,input().split()for _ in range(N)))
S = sum(T)
M = int(input())

for _ in range(M):
    p,x = map(int,input().split())
    S -= T[p-1]
    S += x
    print(S)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
grid = []
for i in range(M):
    data = list(map(int,input().split()))
    grid.append(data)
fsum = sum(T)

for i in range(M):
    dsum = 0
    dsum = fsum - T[i] + grid[i][1]
    print(dsum)

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(max(n, m)):
  print(s - t[p[j]] + x[j])

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(int(s - t[p[j]] + x[j]))

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
s = sum(t)
for j in range(m):
  print(int(s - t[p[j]] + x[j]))

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
s = sum(t)
for j in range(m):
  print(s - t[p[j]] + x[j])

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(s - t[p[j]] + x[j])

Submission status: Runtime Error

Solution code:
n, t, m = int(input()), list(map(int, input().split())), int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(s - t[j] + x[j])

Submission status: Runtime Error

Solution code:
n, t, m = int(input()), list(map(int, input().split())), int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(s - t[i] + x[i])

Submission status: Runtime Error

Solution code:
n, t, m = int(input()), list(map(int, input().split())), int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(sum - t[i] + x[i])

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=t[:]
  tmp[p[0]]=p[1]
  print(sum(tmp))

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T
    T_new[P] = X
    print(np.array(T_new).sum())

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T
    T_new[P = X
    print(np.array(T_new).sum())

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T
    T_new[P[i]] = X
    print(np.array(T_new).sum())

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int(input().split()))
    
    T_new = T
    T_new[P[i]] = X
    print(np.array(T_new).sum())

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(len(M)):
    P, X = map(int(input().split()))
    
    T_new = T
    T_new[P[i]] = X
    print(np.array(T_new).sum())

Submission status: Runtime Error

Solution code:
def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [int(input()) for _ in range(m)]

    main(n, t, m, p_x)

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input()))
m = int(input())
sum = sum(l)
copy = sum

for i in range(m):
  sum = copy
  a,b = map(int,input().split())
  sum += b - l[a-1]
  print(sum)

Submission status: Runtime Error

Solution code:
import numpy as np
#import copy
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])
sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    print(sumT - time[PP-1] + x[PP-1])

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  print(sum(a)-a[p]+x)

Submission status: Runtime Error

Solution code:
N=int(input())
T_N=int(input().split())
list_time = []
for i in range(N):
    list_time.append(T_N[i])
#Ti秒の総和を求める
sum=sum(list_time)
M=int(input())
for i in range(M):
    p,x=map(int,input().split())
    #ドリンク飲んだ時と飲まないときの差を元の合計に足す。
    ans=sum+x-list_time[p-1]
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
T_N=int(input().split())
list_time=[]
for i in range(N):
    list_time.append(T_N[i])
#Ti秒の総和を求める
sum=sum(list_time)
M=int(input())
for i in range(M):
    p,x=map(int,input.split())
    #ドリンク飲んだ時と飲まないときの差を元の合計に足す。
    ans=sum+(x-list_time[p-1])
    print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
T_N=int(input().split())
list_time=[]
for i in range(N)
    list_time.append(T_N[i])
sum=sum(list_time)
M=int(input())
for i in range(M):
    p,x=map(int,input.split())
    ans=sum+(x-list_time[p-1])
    print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
T_N=int(input().split())
list_time=[]
for i in range(N)
    list_time.append(T_N[i])
#Ti秒の総和を求める
sum=sum(list_time)
M=int(input())
for i in range(M):
    p,x=map(int,input.split())
    #ドリンク飲んだ時と飲まないときの差を元の合計に足す。
    ans=sum+(x-list_time[p-1])
    print(ans)

Submission status: Runtime Error

Solution code:
package main

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

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

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	n := nextInt()
	ts := nextInts(n)
	m := nextInt()

	for i := 0; i < m; i++ {
		p, x := nextInt()-1, nextInt()
		ans := 0
		for j := 0; j < n; j++ {
			if j != p {
				ans += ts[j]
			} else {
				ans += x
			}
		}
		fmt.Fprint(out, ans, "\n")
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

s = sum(T)
for i in range(N):
  P, X = map(int, input().split())
  print(s - T[P-1] + X)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split())) 

M = int(input())        


ans = T
number = []
for _ in range(M):
    P, X = map(int, input().split())
    ans[P] = X
    number.append(sum(ans))
    ans = T

for i in number:
    print(i)

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [list(map(int,input().split())) for _ in range(m)]

for i in range(m):
    print(sum(t)-t[px[i][0]]+px[i][1])

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [list(map(int,input().split())) for _ in range(m)]

for i in range(m):
    print(sum(t)-t[i]+px[i][1])

Submission status: Runtime Error

Solution code:
N=int(input())
T=list(map(int,input().split()))
TA=sum(T)
M=int(input())
for i in range(M):
  P,X=map(int,input().split())
  ans=TA+X-T[p-1]
  print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
T=list(map(int,input().split()))
TA=sum(T)
M=int(input())
for i in range(M):
  P,X=map(int,input().split())
  ans=TA+X+T[p-1]
  print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
T=list(map(int,input().split()))
M=int(input())
for i in range(M):
  P[i],X[i]=int(input().split())
  
T_ALL=sum(T)
  
for i in range():
  ans=T_ALL+X[P[i]]-T[i]
  print(ans)

Submission status: Runtime Error

Solution code:
yandy
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())

ans = sum(t)
for i in range(m):
    p, x = map(int, input().split())
    print(ans - t[p-1] + x)

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s-a[p]+x)

Submission status: Runtime Error

Solution code:
N=int(input())
T=list(map(int,input().split())
M=int(input())
Ans=sum(T)
for i in range(M):
  p,x=map(int,input().split())
  xx=Ans+x-T[p-1]
  print(x)

Submission status: Runtime Error

Solution code:
N=int(input())
T=list(map(int,input().split())
M=int(input())
Ans=sum(T)
for i in range(M):
  p,x=map(int,input().split()))
  xx=Ans+x-T[p-1]
  print(x)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(M):
    count = c
    count += X[i]
    count -= T[P[i]]
    print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(len(X)):
    count = c
    count += X[i]
    count -= T[i]
    print(count)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(len(X)):
    count = c
    count += X[i]
    count -= T[i]
    print(count

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    pi, xi = map(int, input().split)
    P.append(pi)
    X.append(xi)

count = 0
for i in T:
    count += T[i]

for i in X:
    count += X[i]
    count -= T[i]
    print(count

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split)
    P.append(p1)
    X.append(x1)

count = 0
for i in T:
    count += T[i]

discount = 0
for i in T:
    if i <= M:
        discount += T[i]

special = 0
for i in P, X:
    special += P[i]
    special += X[i]

count *= M
count -= discount
count += special

print(count)

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    p,x = map(int,input().split())
print(sum[t]-t[p-1]+x)

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    p,x = map(int,input().split())
print(sum[t]-t[m-1]+x)

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
juice=[]
for i in range(m):
	juice.append(list(map(int,input().split())))

for i in range(m):
	ans=0
	for j in range(n):
		if j==juice[i][0]-1
			ans+=juice[i][1]
		else:
			ans+=t[j]
	print(ans)

Submission status: Runtime Error

Solution code:
import copy

n = int(input())
t_li = list(map(int, input().split()))
m = int(input())
px_li = []
result = []

for i in range(m):
  p, x = map(int, input().split())
  px_li.append([p, x])

for j in range(m):
  c_li = copy.copy(t_li)
  c_li[j] = px_li[j][1]
  result.append(str(sum(c_li)))

string = "\n".join(result)
print(string)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int,input().split()))
ans = sum(T)
M = int(input())
for i in range(M):
    P,X = map(int,input().split())
    t = A[P-1] - X
    print(ans-t)

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]* m 
x=[0]* m 
for i in range(m):
    p[i],x[i]= map(int(input().split()))
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(map(int,input(),split()))
m=int(input())
p=[0]* m 
x=[0]* m 
for i in range(m):
  p[i],x[i]= map(int(input(),split()))
for i in range(m):
  print(sum(t)-t[p[i]-1]+x[i])

Submission status: Runtime Error

Solution code:
n=int(input())
t=list(map(int,input(),split()))
m=int(input())
p=[0]* m 
x=[0]* m 
for i in range(m):
    p[i],x[i]= map(int(input(),split()))
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input(),split()))
m = int(input())
p = [0]* m 
x = [0]* m 
for i in range(m):
    p[i],x[i]= map(int(input(),split()))
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input(),split()))
m = int(input())
p = [0]* m 
x = [0]* m 
for i in range(m):
    p[i],x[i]= map(int(input(),split()))
for i in range(m):
    print(sum(t)-t[p[i]-1]+x[i])

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input(),split()))
m = int(input())
p = [0]* m 
x = [0]* m 
for i in range(m):
    p[i],x[i]= map(int(input(),split()))
print(sum(t)-t[p[i]-1]+x[i])

Submission status: Runtime Error

Solution code:
#n,l = map(int,input().split())
#l = kist(input())

n = int(input())
l = list(map(int,input()))

ttl = sum(l)

m = int(input())

for i in range(m):
    p,x = map(int,input().split())
    print(ttl-l[p-1]+x)

Submission status: Runtime Error

Solution code:
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
for i in range(M):
  p, x = map(int, input().split())
  print(sum(Ts)-T[p-1]+x)

Submission status: Runtime Error

Solution code:
N = int(input())
T = [*map(int, input().split())]

for i in range(int(input())):
    P, X = map(int, input().split())
    t = 0
    
    for j in range(N):
        if j+1 == P: t += X
        else: t += T[j]
    
    print(t)

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
for _ in int(input()):
  p,x = map(int,input().split())
  l=t.copy()
  l[p-1] = x
  print(sum(l))

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    t1,t2 = map(int,input().split())
    p.append(t1)
    x.append(t2)
sum_t = sum(t)
for i in range(m):
    print(sum_t - (t[i] -x[i]))

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
s = sum(t)

for i in range(m):
  p,x = map(int,input().split())
  print(s-t[p+1]+x)

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    print(sumT-T[i]+PX[i][1])

Submission status: Runtime Error

Solution code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
PX = [list(map(int,input().split())) for _ in range(m)]
ans = 10**7
s1 = sum(t)
for i in range(m):
  s2 = s1 - t[PX[i][0]] + PX[i][1]
  ans = min(ans,s2)                         
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
times = map(int, input().split())
M = int(input())
sum_t = sum(times)
for _ in range(M):
  dist, time = map(int, input().split())
  if times[dist-1] >= time:
    print(sum_t-(times[dist-1]-time))
  else:
    print(sum_t+(time-times[dist-1]))

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input().split()))
m = int(input())
p_x = []
for i in range(m):
  p_x.append(list(map(int,input()).split()))
for i in range(m):
  p = p_x[i][0]
  x = p_x[i][1]
  print(sum(l) - l[p-1] + x)

Submission status: Runtime Error

Solution code:
n=int(input())
t=map(int,input().split())
#n==len(t)
m=int(input())
px=[]
for i in range(n):
  px.append(map(input().split()))
res=0
for j in range(m):
  for k in range(n):	
    if j==px[j][0]:
      res+=px[j][1]
    else:
      res+=t[k]
  print(res)
  res=0

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())

for i in range(N):
  P,X = list(map(int,input().split()))
  Z = T[:]
  Z[P-1] = X
  print(sum(Z))

Submission status: Runtime Error

Solution code:
##input##
Nvar = int(input())
T_list = map(lambda x:int(x),input().split(" "))
M_var = int(input())
P_dict = {}
for i in range(M_var):
    buf = map(lambda x:int(x),input().split(" "))
    P_dict[buf[0]] = buf[1]
##

time_sum = 0
for d_num in range(M_var):
    for q_num in range(Nvar):
        if q_num==d_num:
            time_sum += P_list[q_num+1]
        else:
            time_sum += T_list[q_num]

Submission status: Runtime Error

Solution code:
N = int(input())
Problems = map(int, input().split())
M = int(input())
arr = []
for i in range(M):
	P, T = map(int, input().split())
    sum = 0
    for j in range(N):
      if j != P:
        sum += Problems[j]
      else:
        sum += T
    arr[i] = sum
for num in arr:
  print(num)

Submission status: Runtime Error

Solution code:
n = int(input())
list = list(map(int, input().split(" ")))
sum = sum(list)
num = int(input())
for x in range(num):
    a = list(map(int, input().split()))
    ans = sum + a[1] - list[a[0]-1]
    print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
list = list(map(int, input().split()))
sum = sum(list)
num = int(input())
for x in range(num):
    a = list(map(int, input().split()))
    ans = sum + a[1] - list[a[0]-1]
    print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < (n);i++)
typedef long long ll;

int main(){
    int n,m;
    int total = 0;
    cin >> n;
    vector<int> t(n);
    rep(i,n){
        cin >> t[i];
        total += t[i];
    }
    cin >> m;
    vector<int> p(m),x(m);
    rep(i,m)cin >> p[i] >> x[i];
    rep(i,m){
        cout << total - (t[p[i]-1] -x[i]) << endl;
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P,X = [list(map(int,input().split())) for _ in range(M)]
all = sum(T)
print(all - T[P-1] + X)

Submission status: Runtime Error

Solution code:
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

    x = [0 for i in range(m)]

    for i in range(m):
        _, x[i] = map(int, input().split())

    for i in range(m):
        print(sum(t) - t[i] + x[i])


if __name__ == "__main__":

    main()

Submission status: Runtime Error

Solution code:
import sys
N = sys.stdin.readline()
T = map(int,sys.stdin.readline().split())
M = sys.stdin.readline()
sum = sum(T)
PX = []
ansList = list(list())
for i in range(M):
    PX.append(map(int,sys.stdin.readline().split()))
for i in range(T):
    ansList[i] = sum[i] + (T[PX[i][0]] - PX[i][1])
    print(ansList[i])

Submission status: Runtime Error

Solution code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for _ in range(M):
  p,x = map(int,input().split())
  P.append(p)
  X.append(x)

sumT = sum(T)

for i,p,x in enumerate(zip(P,X)):
  print(sumT - (T[p]-x))

Submission status: Runtime Error

Solution code:
n = int(inout())
time_list = [ int(v) for v in input().split() ]
total_time = sum(time_list)
m = int(input())

for i in range(m):
  p, t = [ int(v) for v in input().split() ]
  print(total_time - time_list[p-1] + t)

Submission status: Runtime Error

Solution code:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a] + b)

Submission status: Runtime Error

Solution code:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  test[a] = b
  print(sum(test))