import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class wheel_ak {

    static class Edge implements Comparable<Edge> {
        int v1, v2;
        int w;
        boolean inMST;

        Edge(int v1, int v2, int w) {
            this.v1 = v1;
            this.v2 = v2;
            this.w = w;
            inMST = false;
        }

        @Override
        public int compareTo(Edge e) {
            return Long.signum(w - e.w);
        }

        @Override
        public String toString() {
            return "(" + v1 + "--" + v2 + ", w=" + w + ")";
        }
    }

    static class DSU {
        int n;
        int[] p;
        static final Random rnd = new Random(3);

        DSU(int n) {
            this.n = n;
            p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = i;
            }
        }

        int get(int v) {
            return (v == p[v]) ? v : (p[v] = get(p[v]));
        }

        void unite(int v1, int v2) {
            v1 = get(v1);
            v2 = get(v2);
            if (rnd.nextBoolean()) {
                p[v1] = v2;
            } else {
                p[v2] = v1;
            }
        }
    }

    static interface IntComparator {
        int compare(int a, int b);
    }

    static class Max implements IntComparator {
        @Override
        public int compare(int a, int b) {
            return b - a;
        }
    }

    static class Min implements IntComparator {
        @Override
        public int compare(int a, int b) {
            return a - b;
        }
    }

    static class RangeTree {
        int n;
        int[] t, argMin;
        IntComparator comp;

        RangeTree(int n, IntComparator comp) {
            this.comp = comp;
            int m;
            for (m = 1; m < n; m *= 2)
                ;
            n = this.n = m;
            t = new int[2 * n - 1];
            argMin = new int[2 * n - 1];
            for (int i = 0; i < n; i++) {
                argMin[i + n - 1] = i;
            }
            for (int i = 0; i < n - 1; i++) {
                argMin[i] = argMin[2 * i + 1];
            }
        }

        void set(int i, int a) {
            i = i + n - 1;
            t[i] = a;
            while (i != 0) {
                i = (i - 1) / 2;
                if (comp.compare(t[2 * i + 1], t[2 * i + 2]) < 0) {
                    t[i] = t[2 * i + 1];
                    argMin[i] = argMin[2 * i + 1];
                } else {
                    t[i] = t[2 * i + 2];
                    argMin[i] = argMin[2 * i + 2];
                }
            }
        }

        int get(int i) {
            return t[i + n - 1];
        }

        private int argMin(int v, int bLeft, int bRight, int qLeft, int qRight) {
            if (qLeft <= bLeft && bRight <= qRight) {
                return argMin[v];
            }
            if (bRight <= qLeft || qRight <= bLeft) {
                return qLeft;
            }
            int bMid = (bLeft + bRight) / 2;
            int arg1 = argMin(2 * v + 1, bLeft, bMid, qLeft, qRight);
            int arg2 = argMin(2 * v + 2, bMid, bRight, qLeft, qRight);
            if (comp.compare(get(arg1), get(arg2)) < 0)
                return arg1;
            else
                return arg2;
        }

        int argMin(int left, int right) {
            return argMin(0, 0, n, left, right);
        }
    }

    static class CycledRangeTree {
        RangeTree t;
        IntComparator comp;
        int n;

        CycledRangeTree(int n, IntComparator comp) {
            this.n = n;
            this.comp = comp;
            t = new RangeTree(n, comp);
        }

        private int norm(int i) {
            i %= n;
            if (i < 0)
                i += n;
            return i;
        }

        int arg(int left, int right) {
            left = norm(left);
            right = norm(right);
            if (left < right) {
                return t.argMin(left, right);
            } else if (right == 0) {
//                System.err.println("!!" + t.get(0) + " " + t.get(1) + " " + t.get(2) + " " + t.argMin(0, 3));
                return t.argMin(left, n);
            } else if (right <= left) {
                int i1 = t.argMin(left, n);
                int i2 = t.argMin(0, right);
                if (comp.compare(t.get(i1), t.get(i2)) < 0)
                    return i1;
                else
                    return i2;
            } else {
                throw new AssertionError("" + left + " " + right);
            }
        }

        void set(int i, int v) {
            t.set(i, v);
        }

        int get(int i) {
            return t.get(i);
        }
    }

    static class Segment implements Comparable<Segment> {
        final int left;
        final int right;
        int entrance;

        Segment(int left, int right, int entrance) {
            this.left = left;
            this.right = right;
            this.entrance = entrance;
        }

        @Override
        public int compareTo(Segment s) {
            return left - s.left;
        }

        @Override
        public String toString() {
            return "[" + left + "--" + right + " : " + entrance + ")";
        }
    }

    long buildMST(Edge[] edges, int n) {
        Arrays.sort(edges);
        DSU dsu = new DSU(n);
        long wMST = 0;
        for (Edge e : edges) {
            if (dsu.get(e.v1) != dsu.get(e.v2)) {
                dsu.unite(e.v1, e.v2);
                wMST += e.w;
                e.inMST = true;
            }
        }
        return wMST;
    }

    Edge[] edges;
    Edge[] copyOfEdges;
    CycledRangeTree innerMin, outerMin, outerMax /*, innerMax */;
    TreeSet<Segment> segments;
    long mstW;
    int n;

    boolean contains(int left, int mid, int right) {
        right %= n;
        left %= n;
        if (left <= right) {
            return left <= mid && mid < right;
        } else {
            return mid >= left || mid < right;
        }
    }

    void link(Segment s) {
//        System.err.println("Linking " + s);
        if (s.left == s.right) {
//            System.err.println("Full sequence");
            int arg1 = innerMin.arg(0, n - 1);
            int val1 = innerMin.get(arg1);
            int arg2 = innerMin.arg(n - 1, n);
            int val2 = innerMin.get(arg2);
            int arg, val;
            if (val1 < val2) {
                arg = arg1;
            } else {
                arg = arg2;
            }
            val = innerMin.get(arg);
            s.entrance = arg;
            mstW += edges[arg].w;
            edges[arg].inMST = true;
            return;
        }

        int arg1 = innerMin.arg(s.left, s.right);
        int val1 = innerMin.get(arg1);
        int arg2 = (s.left + n - 1) % n;
        int val2 = outerMin.get(arg2);
        int arg3 = (s.right + n - 1) % n;
        int val3 = outerMin.get(arg3);
//        System.err.println("Arc value: " + val1 +"(" + arg1 + ")" + ", left: " + val2 + "(" + arg2 +")" +  ", right: " + val3 + "("+ arg3 + ")");
        if (val1 < val2 && val1 < val3) {
//            System.err.println("Linking to center");
            s.entrance = arg1;
            mstW += edges[arg1].w;
            edges[arg1].inMST = true;
        } else if (val2 < val3) {
            Segment prev = segments.lower(s);
            if (prev == null) {
                prev = segments.last();
            }
//            System.err.println("Link with prev = " + prev);
//            Segment newS = new Segment(prev.left, s.right, prev.entrance);
            Segment newS = new Segment(prev.left, s.right, prev.entrance);
            segments.remove(prev);
            segments.remove(s);
            segments.add(newS);
            edges[arg2 + n].inMST = true;
            mstW += edges[arg2 + n].w;
        } else {
            Segment next = segments.higher(s);
            if (next == null) {
                next = segments.first();
            }
            Segment newS = new Segment(s.left, next.right, next.entrance);
//            System.err.println("Linking with next = " + next + ", me = " + s + ", change to " + newS);
            segments.remove(next);
            segments.remove(s);
            segments.add(newS);
            edges[arg3 + n].inMST = true;
            mstW += edges[arg3 + n].w;
        }
    }

    void setWeight(int e, int newW) {
//        System.err.println("Changing edge " + edges[e] + " id = " + e + " MST before: " + mstW);
        if (e < n) {
            innerMin.set(e, newW);
//            innerMax.set(e, newW);
        } else {
            outerMax.set(e - n, newW);
            outerMin.set(e - n, newW);
        }
        if (edges[e].inMST && edges[e].w >= newW) { // do nothing
            mstW -= edges[e].w;
            mstW += newW;
            edges[e].w = newW;
            return;
        }
        if (!edges[e].inMST && edges[e].w <= newW) { // do nothing
            edges[e].w = newW;
            return;
        }
        if (!edges[e].inMST) { // Tarjan's lemma
//            System.err.println("Not in MST, rebuild required " + (e % n) + " MST: " + mstW);
            edges[e].inMST = true;
            mstW += newW;
            int e2 = e % n; // Position at outer cycle
            if (e >= n) {
                Segment next = segments.ceiling(new Segment((e2 + 1) % n, -1, -1));
                if (next == null) {
                    next = segments.first();
                }
                Segment prev = segments.lower(next);
                if (prev == null) {
                    prev = segments.last();
                }

                if (segments.size() == 1) {
                    int arg = outerMax.arg(0, 0);
                    edges[n + arg].inMST = false;
                    edges[e].w = newW;
                    mstW -= edges[n + arg].w;
//                    System.err.println("Full sequence, throw away " + arg + ", val = " + outerMax.get(arg));
                    Segment newSeq = new Segment((arg + 1) % n, (arg + 1) % n, next.entrance);
                    segments.remove(next);
                    segments.add(newSeq);
                    return;
                }

//                System.err.println("On arc. Neighbours: " + prev + " and " + next);
                int arg1 = outerMax.arg(prev.entrance, next.entrance);
                int val1 = outerMax.get(arg1);
                int arg2 = prev.entrance;
                int val2 = innerMin.get(arg2);
                int arg3 = next.entrance;
                int val3 = innerMin.get(arg3);
                edges[e].w = newW;
                if (val1 > val2 && val1 > val3) { // cut on outer bound
//                    System.err.println("Rebuilding arc, max=" + val1 + "(" + arg1 + ")");
                    Segment s1 = new Segment(prev.left, (arg1 + 1) % n, arg2);
                    Segment s2 = new Segment((arg1 + 1) % n, next.right, arg3);
                    segments.remove(prev);
                    segments.remove(next);
                    segments.add(s1);
                    segments.add(s2);
//                    System.err.println("Changing " + prev + " and " + next + " to " + s1 + " and " + s2 + " --- " + arg1);
                    edges[n + arg1].inMST = false;
                    mstW -= edges[n + arg1].w;
                } else if (val2 > val3) {
                    Segment s = new Segment(prev.left, next.right, arg3);
                    segments.remove(prev);
                    segments.remove(next);
                    segments.add(s);
                    edges[arg2].inMST = false;
                    mstW -= edges[arg2].w;
                } else {
                    Segment s = new Segment(prev.left, next.right, arg2);
                    segments.remove(prev);
                    segments.remove(next);
                    segments.add(s);
                    edges[arg3].inMST = false;
                    mstW -= edges[arg3].w;
                }
            } else {
//                System.err.println("New cycle, last edge: inner " + edges[e]);
                Segment here = segments.floor(new Segment(e2, -1, -1));
                if (here == null) {
                    here = segments.last();
                }
//                System.err.println("It is in segment " + here + " MST: " + mstW);
                edges[e].inMST = true;
                edges[e].w = newW;
                int arg2 = e2;
                int arg3 = here.entrance;
                if (contains(here.left, arg3, arg2)) {
                    int tmp = arg2;
                    arg2 = arg3;
                    arg3 = tmp;
                }
//                System.err.println("Cycle 0--" + (arg2 + 1) +  "..." + (arg3 + 1) + "--0");
                int val2 = innerMin.get(arg2);
                int val3 = innerMin.get(arg3);

                int arg1 = outerMax.arg(arg2, arg3);
                int val1 = outerMax.get(arg1);

//                System.err.println("Arc max: " + val1 + ", left: " + val2 + ", right: " + val3);

                if (val1 > val2 && val1 > val3) {
                    Segment left = new Segment(here.left, (arg1 + 1) % n, arg2);
                    Segment right = new Segment((arg1 + 1) % n, here.right, arg3);
//                    System.err.println("Arc wins! " + here + " -> " + left + " + " + right);
                    segments.remove(here);
                    segments.add(left);
                    segments.add(right);
                    edges[arg1 + n].inMST = false;
                    mstW -= edges[arg1 + n].w;
                } else if (val2 > val3) {
//                    System.err.println("Left wins");
                    edges[arg2].inMST = false;
                    mstW -= edges[arg2].w;
                    here.entrance = arg3;
                } else {
//                    System.err.println("Right wins " + edges[arg3] + " " + arg3);
                    edges[arg3].inMST = false;
                    mstW -= edges[arg3].w;
                    here.entrance = arg2;
                }

            }
            edges[e].w = newW;
            return;
        }
        if (edges[e].inMST && newW > edges[e].w) {
//            System.err.println("In MST");
            edges[e].inMST = false;
            mstW -= edges[e].w;
            edges[e].w = newW;
            int e2 = e % n;
            Segment here = segments.floor(new Segment(e2, -1, -1));
            if (here == null) {
                here = segments.last();
            }
//            System.err.println("Segment to split: " + here);
            if (e >= n) {
                if (contains(here.left, e2, here.entrance)) { // [---cut----old----]
                    Segment newLeft = new Segment(here.left, (e2 + 1) % n, -1);
                    Segment newRight = new Segment((e2 + 1) % n, here.right, here.entrance);
//                    System.err.println("Left is out: left=" + newLeft + ", right=" + newRight);
                    segments.remove(here);
                    segments.add(newLeft);
                    segments.add(newRight);
                    link(newLeft);
                } else {
                    Segment newLeft = new Segment(here.left, (e2 + 1) % n, here.entrance);
                    Segment newRight = new Segment((e2 + 1) % n, here.right, -1);
//                    System.err.println("Right is out: left=" + newLeft + ", right=" + newRight);
                    segments.remove(here);
                    segments.add(newLeft);
                    segments.add(newRight);
                    link(newRight);
                }
            } else {
//                System.err.println("Arc is out. Linking...");
                link(here);
            }
            return;
        }
    }

    void solve() throws IOException {
        n = in.nextInt();
        innerMin = new CycledRangeTree(n, new Min());
        outerMin = new CycledRangeTree(n, new Min());
        outerMax = new CycledRangeTree(n, new Max());
        edges = new Edge[2 * n];
        copyOfEdges = new Edge[2 * n];
        for (int i = 0; i < n; i++) {
            copyOfEdges[i] = edges[i] = new Edge(0, i + 1, in.nextInt());
            innerMin.set(i, edges[i].w);
        }
        for (int i = 0; i < n; i++) {
            copyOfEdges[i + n] = edges[i + n] = new Edge(i + 1, (i + 1) % n + 1, in.nextInt());
            outerMax.set(i, edges[i + n].w);
            outerMin.set(i, edges[i + n].w);
        }
        mstW = buildMST(copyOfEdges, n + 1);

//        System.err.print("MST: ");
//        for (Edge e : edges) {
//            if (e.inMST) {
//                System.err.print(e + " ");
//            }
//        }
//        System.err.println();

        segments = new TreeSet<>();
        int start = 0;
        for ( ; edges[start + n].inMST; start++)
            ;
        start = (start + 1) % n;
        int oldStart = start;
        int finish = start + 1;
        while (finish != oldStart) {
            finish = (start) % n;
            while (edges[finish + n].inMST) {
                finish = (finish + 1) % n;
            }
            finish = (finish + 1) % n;
            int enter = -1;
            boolean started = false;
            for (int i = start; i != finish || !started; i = (i + 1) % n) {
                started =true;
                if (edges[i].inMST) {
                    enter = i;
                }
            }
            Segment s = new Segment(start, finish, enter);
            segments.add(s);
            start = finish;
        }

//        System.err.println("Segments: " + segments);

        out.println(mstW);

        int m = in.nextInt();
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a > b) {
                int tmp = a;
                a = b;
                b = tmp;
            }
            int e = -1;
            if (a == 0)
                e = b - 1;
            else if (a != 1) {
                e = a + n - 1;
            } else if (b == 2) {
                e = n;
            } else {
                e = 2 * n - 1;
            }
            int newW = in.nextInt();
            setWeight(e, newW);

//            System.err.println("===================");
//            System.err.println("MST: ");
//            for (Edge eee : edges) {
//                if (eee.inMST) {
//                    System.err.print(eee + " ");
//                }
//            }
//            System.err.println("Segments: " + segments);

            out.println(mstW);
        }
    }

    static MyScanner in;
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        in = new MyScanner(new FileReader("wheel.in"));
        out = new PrintWriter("wheel.out");
        new wheel_ak().solve();
        out.close();
    }

    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(Reader r) {
            br = new BufferedReader(r);
        }

        String nextToken() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(nextToken());
        }
    }

}
