import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;

public class Main {

    static int N;
    static int[] V, T;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        V = sc.nextIntArray(N);
        T = sc.nextIntArray(N);

        long[] ans = solve();
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < N; i++) {
            if ( i != 0 ) pw.print(" ");
            pw.print(ans[i]);
        }
        pw.println();
        pw.flush();
    }

    static long[] solve() {
        int[] CT = new int[N];
        CT[0] = T[0];
        for (int i = 1; i < N; i++) {
            CT[i] = CT[i-1] + T[i];
        }

        int[] imos = new int[N+1];
        int[] remains = new int[N+1];

        for (int i = 0; i < N; i++) {
            int prev = i == 0 ? 0 : CT[i-1];
            // [i, j)
            int j = upperBound(CT, prev + V[i]);
            imos[i]++;
            imos[j]--;
            remains[j] += V[i] - (CT[j-1] - (i==0 ? 0 : CT[i-1]));
        }

        for (int i = 1; i < N; i++) {
            imos[i] += imos[i-1];
        }

        long[] ans = new long[N];
        for (int i = 0; i < N; i++) {
            ans[i] = (long)imos[i] * T[i] + remains[i];
        }
        return ans;
    }

    static int upperBound(int[] array, int value) {
        int low = 0;
        int high = array.length;
        int mid;
        while( low < high ) {
            mid = ((high - low) >>> 1) + low; // (high + low) / 2
            if( array[mid] <= value ) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static <A> void writeLines(A[] as, Function<A, String> f) {
        PrintWriter pw = new PrintWriter(System.out);
        for (A a : as) {
            pw.println(f.apply(a));
        }
        pw.flush();
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }
}


import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;

public class Main {

    static int N;
    static int[] V, T;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        V = sc.nextIntArray(N);
        T = sc.nextIntArray(N);

        long[] ans = solve();
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < N; i++) {
            if ( i != 0 ) pw.print(" ");
            pw.print(ans[i]);
        }
        pw.println();
        pw.flush();
    }

    static long[] solve() {
        int[] CT = new int[N];
        CT[0] = T[0];
        for (int i = 1; i < N; i++) {
            CT[i] = CT[i-1] + T[i];
        }

        int[] imos = new int[N+1];
        int[] remains = new int[N+1];

        for (int i = 0; i < N; i++) {
            int prev = i == 0 ? 0 : CT[i-1];
            // [i, j)
            int j = upperBound(CT, prev + V[i]);

            if( i == j ) {
                remains[i] = V[i];

            } else {
                imos[i]++;
                imos[j]--;
                remains[j] += V[i] - (CT[j-1] - (i==0 ? 0 : CT[i-1]));
            }
        }

        for (int i = 1; i < N; i++) {
            imos[i] += imos[i-1];
        }

        long[] ans = new long[N];
        for (int i = 0; i < N; i++) {
            ans[i] = (long)imos[i] * T[i] + remains[i];
        }
        return ans;
    }

    static int upperBound(int[] array, int value) {
        int low = 0;
        int high = array.length;
        int mid;
        while( low < high ) {
            mid = ((high - low) >>> 1) + low; // (high + low) / 2
            if( array[mid] <= value ) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static <A> void writeLines(A[] as, Function<A, String> f) {
        PrintWriter pw = new PrintWriter(System.out);
        for (A a : as) {
            pw.println(f.apply(a));
        }
        pw.flush();
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }
}


import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;

public class Main {

    static int N;
    static int[] V, T;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        V = sc.nextIntArray(N);
        T = sc.nextIntArray(N);

        long[] ans = solve();
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < N; i++) {
            if ( i != 0 ) pw.print(" ");
            pw.print(ans[i]);
        }
        pw.println();
        pw.flush();
    }

    static long[] solve() {
        long[] CT = new long[N];
        CT[0] = T[0];
        for (int i = 1; i < N; i++) {
            CT[i] = CT[i-1] + T[i];
        }

        int[] imos = new int[N+1];
        long[] remains = new long[N+1];

        for (int i = 0; i < N; i++) {
            long prev = i == 0 ? 0 : CT[i-1];
            // [i, j)
            int j = upperBound(CT, prev + V[i]);

            if( i == j ) {
                remains[i] += V[i];

            } else {
                imos[i]++;
                imos[j]--;
                remains[j] += V[i] - (CT[j-1] - (i==0 ? 0 : CT[i-1]));
            }
        }

        for (int i = 1; i < N; i++) {
            imos[i] += imos[i-1];
        }

        long[] ans = new long[N];
        for (int i = 0; i < N; i++) {
            ans[i] = (long)imos[i] * T[i] + remains[i];
        }
        return ans;
    }

    static int upperBound(long[] array, long value) {
        int low = 0;
        int high = array.length;
        int mid;
        while( low < high ) {
            mid = ((high - low) >>> 1) + low; // (high + low) / 2
            if( array[mid] <= value ) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static <A> void writeLines(A[] as, Function<A, String> f) {
        PrintWriter pw = new PrintWriter(System.out);
        for (A a : as) {
            pw.println(f.apply(a));
        }
        pw.flush();
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }
}


import java.io.*;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.Function;

public class Main {

    static int N;
    static int[] V, T;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        V = sc.nextIntArray(N);
        T = sc.nextIntArray(N);

        long[] ans = solve();
        PrintWriter pw = new PrintWriter(System.out);
        for (int i = 0; i < N; i++) {
            if ( i != 0 ) pw.print(" ");
            pw.print(ans[i]);
        }
        pw.println();
        pw.flush();
    }

    static long[] solve() {
        int[] CT = new int[N];
        CT[0] = T[0];
        for (int i = 1; i < N; i++) {
            CT[i] = CT[i-1] + T[i];
        }

        int[] imos = new int[N+1];
        int[] remains = new int[N+1];

        for (int i = 0; i < N; i++) {
            int prev = i == 0 ? 0 : CT[i-1];
            // [i, j)
            int j = upperBound(CT, prev + V[i]);

            if( i == j ) {
                remains[i] += V[i];

            } else {
                imos[i]++;
                imos[j]--;
                remains[j] += V[i] - (CT[j-1] - (i==0 ? 0 : CT[i-1]));
            }
        }

        for (int i = 1; i < N; i++) {
            imos[i] += imos[i-1];
        }

        long[] ans = new long[N];
        for (int i = 0; i < N; i++) {
            ans[i] = (long)imos[i] * T[i] + remains[i];
        }
        return ans;
    }

    static int upperBound(int[] array, int value) {
        int low = 0;
        int high = array.length;
        int mid;
        while( low < high ) {
            mid = ((high - low) >>> 1) + low; // (high + low) / 2
            if( array[mid] <= value ) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        return low;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        int[] nextIntArray(int n, int delta) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt() + delta;
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static <A> void writeLines(A[] as, Function<A, String> f) {
        PrintWriter pw = new PrintWriter(System.out);
        for (A a : as) {
            pw.println(f.apply(a));
        }
        pw.flush();
    }

    static void writeLines(int[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (int a : as) pw.println(a);
        pw.flush();
    }

    static void writeLines(long[] as) {
        PrintWriter pw = new PrintWriter(System.out);
        for (long a : as) pw.println(a);
        pw.flush();
    }

    static int max(int... as) {
        int max = Integer.MIN_VALUE;
        for (int a : as) max = Math.max(a, max);
        return max;
    }

    static int min(int... as) {
        int min = Integer.MAX_VALUE;
        for (int a : as) min = Math.min(a, min);
        return min;
    }

    static void debug(Object... args) {
        StringJoiner j = new StringJoiner(" ");
        for (Object arg : args) {
            if (arg instanceof int[]) j.add(Arrays.toString((int[]) arg));
            else if (arg instanceof long[]) j.add(Arrays.toString((long[]) arg));
            else if (arg instanceof double[]) j.add(Arrays.toString((double[]) arg));
            else if (arg instanceof Object[]) j.add(Arrays.toString((Object[]) arg));
            else j.add(arg.toString());
        }
        System.err.println(j.toString());
    }
}


import java.util.*;

/**
 * Created by ASUS on 10/03/2018.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] v = new long[n];
        long[] vprime = new long[n];
        long[] t = new long[n];
        long[] ft = new long[n + 1];

        long[] meltOn = new long[n];
        for (int i = 0; i < n; i++) {
            v[i] = in.nextLong();
        }
        for (int i = 0; i < n; i++) {
            t[i] = in.nextLong();
        }
        ft[0] = 0;
        for (int i = 1; i <= n; i++) {
            ft[i] = ft[i - 1] + t[i - 1];
        }
        PriorityQueue<Long> pq = new PriorityQueue<>();
        vprime[0] = v[0];
        for (int i = 1; i < n; i++) {
            vprime[i] = ft[i] + v[i];
        }
        for (int i = 0; i < n; i++) {
            long d = 0;
            pq.add((long) vprime[i]);
            while (!pq.isEmpty() && pq.peek() <= ft[i + 1]) {
                d += pq.remove() - ft[i];
            }
            d += pq.size() * t[i];
            meltOn[i] = d;

        }

        for (int i = 0; i < n; i++) {
            System.out.print(meltOn[i] + " ");
        }

    }
}


import java.util.*;

/**
 * Created by ASUS on 10/03/2018.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] v = new long[n];
        long[] vprime = new long[n];
        long[] t = new long[n];
        long[] ft = new long[n + 1];

        long[] meltOn = new long[n];
        for (int i = 0; i < n; i++) {
            v[i] = in.nextLong();
        }
        for (int i = 0; i < n; i++) {
            t[i] = in.nextLong();
        }
        ft[0] = 0;
        for (int i = 1; i < n; i++) {
            ft[i] = ft[i - 1] + t[i];
        }
        PriorityQueue<Long> pq = new PriorityQueue<>();
        vprime[0] = v[0];
        for (int i = 1; i < n; i++) {
            vprime[i] = ft[i] + v[i];
        }
        for (int i = 0; i < n; i++) {
            long d = 0;
            pq.add((long) vprime[i]);
            while (!pq.isEmpty() && pq.peek() <= ft[i + 1]) {
                d += pq.remove() - ft[i];
            }
            d += pq.size() * t[i];
            meltOn[i] = d;

        }

        for (int i = 0; i < n; i++) {
            System.out.print(meltOn[i] + " ");
        }

    }
}


import java.util.*;

/**
 * Created by ASUS on 10/03/2018.
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long[] v = new long[n];
        long[] vprime = new long[n];
        long[] t = new long[n];
        long[] ft = new long[n];

        long[] meltOn = new long[n];
        for (int i = 0; i < n; i++) {
            v[i] = in.nextLong();
        }
        for (int i = 0; i < n; i++) {
            t[i] = in.nextLong();
        }
        ft[0] = t[0];
        for (int i = 1; i < n; i++) {
            ft[i] = ft[i - 1] + t[i];
        }
        PriorityQueue<Long> pq = new PriorityQueue<>();
        vprime[0] = v[0];
        for (int i = 1; i < n; i++) {
            vprime[i] = ft[i - 1] + v[i];
        }
        for (int i = 0; i < n; i++) {
            long d = 0;
            pq.add((long) vprime[i]);
            while (!pq.isEmpty() && pq.peek() <= ft[i]) {
                d += pq.remove() - ft[i - 1];
            }
            d += pq.size() * t[i];
            meltOn[i] = d;

        }

        for (int i = 0; i < n; i++) {
            System.out.print(meltOn[i] + " ");
        }

    }
}


import java.util.*;
import java.io.*;

public class Producing_Snow {

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader t = new FastReader();
		PrintWriter o = new PrintWriter(System.out);
		int n = t.nextInt();
		PriorityQueue<Long> pq = new PriorityQueue<>();
		long[] a = new long[n];
		StringBuilder sb = new StringBuilder();
		long delta = 0;

		for (int i = 0; i < n; ++i)
			a[i] = t.nextLong();

		for (int i = 0; i < n; ++i) {
			long snow = t.nextLong();
			long ans = 0;

			pq.add(a[i] + delta);

			while (pq.size() > 0 && pq.peek() <= snow + delta) {
				ans += (pq.remove() - delta);
			}

			delta += snow;

			ans += pq.size() * snow;

			sb.append(ans + " ");
		}

		o.println(sb);
		o.flush();
		o.close();
	}
}


import java.io.*;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class TaskB {

	public static void main(String[] args) throws Exception {
		Tokenizer in = new Tokenizer();

		int n = in.nextInt();

		long[] v = new long[n];
		for(int i = 0; i < n; i++) v[i] = in.nextLong();

		long[] t = new long[n];
		for(int i = 0; i < n; i++) t[i] = in.nextLong();

		long[] prefix = new long[n];
		prefix[0] = t[0];
		for(int i = 1; i < n; i++) prefix[i] = prefix[i - 1] + t[i];

		//System.out.println(Arrays.toString(prefix));

		PriorityQueue<Event> events = new PriorityQueue<>();
		for(int i = 0; i < n; i++) events.add(new Event(3, i)); // 3 - end of day
		for(int i = 0; i < n; i++) events.add(new Event(1, i)); // 1 - sugrob creation

		for(int i = 0; i < n; i++) {
			long offset = i == 0 ? 0 : prefix[i - 1];

			int index = Arrays.binarySearch(prefix, offset + v[i]);
			if(index >= 0) { // found in array
				events.add(new Event(2, index + 1, 0)); // Полностью растает
			} else {
				//System.out.println(index);
				index = -(index + 1);
				//System.out.println((prefix[i] + v[i]) + " " + index);
				long pp = index == 0 ? 0 : prefix[index - 1];
				events.add(new Event(2, index, v[i] - (pp - offset)));
			}
		}

		int counter = 0;
		long ost = 0;
		while(!events.isEmpty()) {
			Event current = events.poll();
			//System.out.println(current);

			switch(current.type) {
				case 1:
					counter++;
					break;
				case 2:
					counter--;
					ost += current.value;
					break;
				case 3:
					System.out.print((counter * t[current.day] + ost) + " ");
					ost = 0;
					break;
			}
		}
		System.out.println();
	}

	private static class Event implements Comparable<Event> {

		public final int type, day;
		public final long value;

		public Event(int t, int d) {
			type = t; day = d; value = 0;
		}

		public Event(int t, int d, long v) {
			type = t; day = d; value = v;
		}

		@Override
		public int compareTo(Event o) {
			if(day != o.day) return Integer.compare(day, o.day);
			return Integer.compare(type, o.type);
		}

		@Override
		public String toString() {
			if(type == 1) return "ADD";
			if(type == 2) return "REMOVE " + value;
			return "-- END OF DAY --";
		}

	}

	private static class Tokenizer {

		private final BufferedReader in;
		private StringTokenizer tokenizer = null;

		public Tokenizer() throws Exception {
			this(new InputStreamReader(System.in));
		}

		public Tokenizer(Reader reader) throws Exception {
			in = new BufferedReader(reader);
		}

		public boolean hasMoreTokens() throws Exception {
			while(tokenizer == null || !tokenizer.hasMoreTokens()) {
				String line = in.readLine();
				if(line == null) return false;
				tokenizer = new StringTokenizer(line);
			}
			return true;
		}

		public String next() throws Exception {
			return hasMoreTokens() ? tokenizer.nextToken() : null;
		}

		public int nextInt() throws Exception {
			return Integer.parseInt(next());
		}

		public long nextLong() throws Exception {
			return Long.parseLong(next());
		}

	}

}


import java.io.*;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class TaskB {

	public static void main(String[] args) throws Exception {
		Tokenizer in = new Tokenizer();

		int n = in.nextInt();

		long[] v = new long[n];
		for(int i = 0; i < n; i++) v[i] = in.nextLong();

		long[] t = new long[n];
		for(int i = 0; i < n; i++) t[i] = in.nextLong();

		long[] prefix = new long[n];
		prefix[0] = t[0];
		for(int i = 1; i < n; i++) prefix[i] = prefix[i - 1] + t[i];

		//System.out.println(Arrays.toString(prefix));

		PriorityQueue<Event> events = new PriorityQueue<>();
		for(int i = 0; i < n; i++) events.add(new Event(3, i)); // 3 - end of day
		for(int i = 0; i < n; i++) events.add(new Event(1, i)); // 1 - sugrob creation

		for(int i = 0; i < n; i++) {
			long offset = i == 0 ? 0 : prefix[i - 1];

			int index = Arrays.binarySearch(prefix, offset + v[i]);
			if(index >= 0) { // found in array
				events.add(new Event(2, index + 1, 0)); // Полностью растает
			} else {
				//System.out.println(index);
				index = -(index + 1);
				//System.out.println((prefix[i] + v[i]) + " " + index);
				events.add(new Event(2, index, v[i] - (prefix[index - 1] - offset)));
			}
		}

		int counter = 0;
		long ost = 0;
		while(!events.isEmpty()) {
			Event current = events.poll();
			//System.out.println(current);

			switch(current.type) {
				case 1:
					counter++;
					break;
				case 2:
					counter--;
					ost += current.value;
					break;
				case 3:
					System.out.print((counter * t[current.day] + ost) + " ");
					ost = 0;
					break;
			}
		}
		System.out.println();
	}

	private static class Event implements Comparable<Event> {

		public final int type, day;
		public final long value;

		public Event(int t, int d) {
			type = t; day = d; value = 0;
		}

		public Event(int t, int d, long v) {
			type = t; day = d; value = v;
		}

		@Override
		public int compareTo(Event o) {
			if(day != o.day) return Integer.compare(day, o.day);
			return Integer.compare(type, o.type);
		}

		@Override
		public String toString() {
			if(type == 1) return "ADD";
			if(type == 2) return "REMOVE " + value;
			return "-- END OF DAY --";
		}

	}

	private static class Tokenizer {

		private final BufferedReader in;
		private StringTokenizer tokenizer = null;

		public Tokenizer() throws Exception {
			this(new InputStreamReader(System.in));
		}

		public Tokenizer(Reader reader) throws Exception {
			in = new BufferedReader(reader);
		}

		public boolean hasMoreTokens() throws Exception {
			while(tokenizer == null || !tokenizer.hasMoreTokens()) {
				String line = in.readLine();
				if(line == null) return false;
				tokenizer = new StringTokenizer(line);
			}
			return true;
		}

		public String next() throws Exception {
			return hasMoreTokens() ? tokenizer.nextToken() : null;
		}

		public int nextInt() throws Exception {
			return Integer.parseInt(next());
		}

		public long nextLong() throws Exception {
			return Long.parseLong(next());
		}

	}

}


import java.io.*;
import java.util.*;
import java.math.*;

public class ProducingSnow {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter pw = new PrintWriter(System.out), pw2 = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        int n=sc.nextInt();
        int[] snow=new int[n];
        for(int i=0;i<n;i++)
            snow[i]=sc.nextInt();
        int[] temp=new int[n];
        for(int i=0;i<n;i++)
            temp[i]=sc.nextInt();
        PriorityQueue<Long> pq=new PriorityQueue<>();
        ArrayList<Long> days=new ArrayList<>();
        long prev=0;
        for(int i=0;i<n;i++){
            long melted=0;
            pq.add(snow[i]*1l+prev);
            while(!pq.isEmpty()&&pq.peek()-prev<temp[i])
                melted+=pq.poll()-prev;
            days.add(1l*temp[i]*pq.size()+melted);
            prev+=temp[i];
        }
        for(long x:days)
            pw.print(x+" ");
        pw.flush();
    }

    public static <E> void print2D(E[][] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                pw.println(arr[i][j]);
            }
        }
    }

    public static int digitSum(String s) {
        int toReturn = 0;
        for (int i = 0; i < s.length(); i++) toReturn += Integer.parseInt(s.charAt(i) + " ");
        return toReturn;
    }

    public static boolean isPrime(long n) {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (long i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;
        return true;
    }

    public static long pow(long a, long pow) {
        return pow == 0 ? 1 : pow % 2 == 0 ? pow(a * a, pow >> 1) : a * pow(a * a, pow >> 1);
    }

    public static long sumNum(long a) {
        return a * (a + 1) / 2;
    }

    public static int gcd(int n1, int n2) {
        return n2 == 0 ? n1 : gcd(n2, n1 % n2);
    }

    public static long factorial(long a) {
        return a == 0 || a == 1 ? 1 : a * factorial(a - 1);
    }

    public static void sort(int arr[]) {
        shuffle(arr);
        Arrays.sort(arr);
    }

    public static void shuffle(int arr[]) {
        Random rnd = new Random();
        for (int i = arr.length - 1; i > 0; i--) {
            int index = rnd.nextInt(i + 1);
            int temp = arr[index];
            arr[index] = arr[i];
            arr[i] = temp;
        }
    }

    public static Double[] solveQuadratic(double a, double b, double c) {
        double result = (b * b) - 4.0 * a * c;
        double r1;
        if (result > 0.0) {
            r1 = ((double) (-b) + Math.pow(result, 0.5)) / (2.0 * a);
            double r2 = ((double) (-b) - Math.pow(result, 0.5)) / (2.0 * a);
            return new Double[]{r1, r2};
        } else if (result == 0.0) {
            r1 = (double) (-b) / (2.0 * a);
            return new Double[]{r1, r1};
        } else {
            return new Double[]{null, null};
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

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

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

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

    static class pair<E1, E2> implements Comparable<pair> {
        E1 x;
        E2 y;

        pair(E1 x, E2 y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(pair o) {
            return x.equals(o.x) ? (Integer) y - (Integer) o.y : (Integer) x - (Integer) o.x;
        }

        @Override
        public String toString() {
            return x + " " + y;
        }

        public double pointDis(pair p1) {
            return Math.sqrt(((Integer) y - (Integer) p1.y) * ((Integer) y - (Integer) p1.y) + ((Integer) x - (Integer) p1.x) * ((Integer) x - (Integer) p1.x));
        }
    }

}


// package ArraysAndSearching;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class SnowMaking {
    public static int getIndex(long sum[],long value,int n){
        int low=0,high=n,ans=0;
        while(low<=high){
            int mid=(low+high)/2;
            if(sum[mid]<=value){
                ans=mid;
                low=mid+1;
            }
            else{
                high=mid-1;
            }
        }
        return ans;
    }
    public static void print(int a[]){
        for(int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
    }
    public static void print(long a[]){
        for(int i=0;i<a.length;i++){
            System.out.print(a[i]+" ");
        }
        System.out.println();
    }
    public static void main(String[] args)throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int v[]=new int[n+1];
        String line[]=br.readLine().split(" ");
        for(int i=1;i<=n;i++){
            v[i]=Integer.parseInt(line[i-1]);
        }
        int t[]=new int[n+1];
        long sum[]=new long[n+1];
        line=br.readLine().split(" ");
        for(int i=1;i<=n;i++){
            t[i]=Integer.parseInt(line[i-1]);
            sum[i]=sum[i-1]+t[i];
        }
        long count[]=new long[n+2];
        int prefix[]=new int[n+2];
        for(int i=1;i<=n;i++){
            if(v[i]<=t[i]){
                count[i]+=v[i];
                continue;
            }
            int index=getIndex(sum,sum[i-1]+v[i],n);
//            System.out.println(i+" "+index);
            prefix[i]++;
            prefix[index+1]--;
            count[index+1]+=sum[i-1]+v[i]-sum[index];
        }
        int prefix_sum[]=new int[n+2];
        prefix_sum[0]=prefix[0];
        for(int i=1;i<=n;i++){
            prefix_sum[i]=prefix_sum[i-1]+prefix[i];
        }
//        print(v);
//        print(t);
//        print(sum);
//        print(prefix);
//        print(prefix_sum);
//        print(count);
        StringBuilder print=new StringBuilder();
        for(int i=1;i<=n;i++){
            long temp=1l*t[i]*prefix_sum[i]+count[i];
            print.append(temp+" ");
        }
        System.out.println(print.toString());
    }
}


import java.io.*;
import java.util.*;
import java.util.concurrent.ExecutionException;

public class Main {

    private void solve(FastScanner in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        long[] vi = in.nextLongs(n);
        long[] ti = in.nextLongs(n);
        PriorityQueue<Long> pq = new PriorityQueue<>();
        long currentSum = 0;
        for (int i = 0; i < n; i++) {
            pq.add(currentSum + vi[i]);
            long curAnswer = 0;
            while (!pq.isEmpty() && pq.peek() <= currentSum + ti[i]) {
                curAnswer += pq.poll() - currentSum;
            }
            curAnswer += pq.size() * ti[i];
            out.print(curAnswer);
            out.print(i == n - 1 ? '\n' : ' ');
            currentSum += ti[i];
        }
    }

    private void run() throws IOException, ExecutionException, InterruptedException {
        FastScanner in = new FastScanner();
        PrintWriter out = new PrintWriter(System.out, false);
        solve(in, out);
        out.flush();
    }

    void check(boolean b) {
        if (!b) throw new RuntimeException();
    }

    public static void main(String[] args) throws IOException, ExecutionException, InterruptedException {
//        Integer stackSize = null;
        Integer stackSize = 1 << 28; // 256mb
        if (stackSize != null) {
            new Thread(null, new Runnable() {
                @Override
                public void run() {
                    try {
                        new Main().run();
                    } catch (IOException | ExecutionException | InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }, "", stackSize).start();
        } else {
            new Main().run();
        }
    }
}

class FastScanner {
    private final BufferedReader br;
    private StringTokenizer st;
    private String last;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    public FastScanner(String path) throws IOException {
        br = new BufferedReader(new FileReader(path));
    }

    public FastScanner(String path, String decoder) throws IOException {
        br = new BufferedReader(new InputStreamReader(new FileInputStream(path), decoder));
    }

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

    String nextLine() throws IOException {
        st = null;
        return (last == null) ? br.readLine() : last;
    }

    boolean hasNext() {
        if (st != null && st.hasMoreElements())
            return true;

        try {
            while (st == null || !st.hasMoreElements()) {
                last = br.readLine();
                st = new StringTokenizer(last);
            }
        } catch (Exception e) {
            return false;
        }

        return true;
    }

    String[] nextStrings(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = next();
        return arr;
    }

    String[] nextLines(int n) throws IOException {
        String[] arr = new String[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLine();
        return arr;
    }

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

    int[] nextInts(int n) throws IOException {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    Integer[] nextIntegers(int n) throws IOException {
        Integer[] arr = new Integer[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextInt();
        return arr;
    }

    int[][] next2Ints(int n, int m) throws IOException {
        int[][] arr = new int[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextInt();
        return arr;
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    long[] nextLongs(int n) throws IOException {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++)
            arr[i] = nextLong();
        return arr;
    }

    long[][] next2Longs(int n, int m) throws IOException {
        long[][] arr = new long[n][m];
        for (int i = 0; i < n; i++)
            for (int j = 0; j < m; j++)
                arr[i][j] = nextLong();
        return arr;
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next().replace(',', '.'));
    }

    double[] nextDoubles(int size) throws IOException {
        double[] arr = new double[size];
        for (int i = 0; i < size; i++)
            arr[i] = nextDouble();
        return arr;
    }

    boolean nextBool() throws IOException {
        String s = next();
        if (s.equalsIgnoreCase("true") || s.equals("1"))
            return true;

        if (s.equalsIgnoreCase("false") || s.equals("0"))
            return false;

        throw new IOException("Boolean expected, String found!");
    }

    public double[][] next2Doubles(int n, int m) throws IOException {
        double[][] arr = new double[n][];
        for (int i = 0; i < n; i++) {
            arr[i] = nextDoubles(m);
        }
        return arr;
    }
}


import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
	public static class FastReader {
			BufferedReader br;
			StringTokenizer root;

			public FastReader() {
				br = new BufferedReader(new InputStreamReader(System.in));
			}

			String next() {
				while (root == null || !root.hasMoreTokens()) {
					try {
						root = new StringTokenizer(br.readLine());
					} catch (Exception addd) {
						addd.printStackTrace();
					}
				}
				return root.nextToken();
			}

			int nextInt() {
				return Integer.parseInt(next());
			}

			double nextDouble() {
				return Double.parseDouble(next());
			}

			long nextLong() {
				return Long.parseLong(next());
			}

			String nextLine() {
				String str = "";
				try {
					str = br.readLine();
				} catch (Exception addd) {
					addd.printStackTrace();
				}
				return str;
			}
		}

	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	public static FastReader sc = new FastReader();

	static int mod = (int) (998244353),MAX=(int)(1e5+10);
	static List<Integer>[] edges;

	public static void main(String[] args) throws IOException{

		int n = sc.nextInt();
		int[] a = new int[n+1];
		int[] t = new int[n+1];
		long[] pre = new long[n+10];
		long[] extra = new long[n+10];
		long[] diff = new long[n+10];
		TreeMap<Long,Integer> map = new TreeMap<>();
		for(int i=1;i<=n;++i)
			a[i] = sc.nextInt();

		for(int i=1;i<=n;++i) {
			t[i] = sc.nextInt();
			pre[i] = pre[i-1] + t[i];
			map.putIfAbsent(pre[i],i);
		}

		for(int i=1;i<=n;++i) {
			Long key = map.ceilingKey(a[i]+pre[i-1]);
			if(key == null) {
				diff[i]++;
				diff[n+1]--;
			}else {
				int j = map.get(key);
				diff[i]++;
				if(pre[j] != a[i] + pre[i-1]) {
					extra[j]+= a[i] + pre[i-1] - pre[j-1];
					diff[j]--;
				}else diff[j+1]--;

			}
		}
		long sum = diff[0];
		for(int i=1;i<=n;++i) {
			diff[i]+=sum;
			sum = diff[i];
			diff[i] = t[i]*diff[i] + extra[i];
		}
		for(int i=1;i<=n;++i) out.print(diff[i]+" ");
		out.close();

	}

}


import java.io.*;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class TaskB {
    FastScanner sc;
    PrintWriter out;

    public void solve() throws IOException {
        int n = sc.nextInt();
        long[] v = new long[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }
        long[] t = new long[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }
        PriorityQueue<Long> pq = new PriorityQueue<>();

        StringBuilder sb = new StringBuilder();

        long prev_rez = 0;
        for (int i = 0; i < n; i++) {
            long rezult = 0;
            pq.add(prev_rez + v[i]);
            long tmp = prev_rez + t[i];
            while (!pq.isEmpty() && pq.peek() <= tmp) {
                rezult += pq.poll() - prev_rez;
            }
            rezult += t[i] * pq.size();

            prev_rez += t[i];

            sb.append(rezult).append(" ");
//            System.out.println(rezult);
        }
        out.println(sb.toString());

    }

    public void run() {
        try {
            sc = new FastScanner(System.in);
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

        FastScanner(File f) throws FileNotFoundException {
            this(new FileInputStream(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] arg) {
        new TaskB().run();
    }
}


/*package whatever //do not write package name here */

import java.util.*;

public class snow {

	public static void main(String args[])
	{
	 Scanner s=new Scanner(System.in);
	 int n=s.nextInt();
	 int arr[]=new int[n];
	 for(int i=0;i<n;i++)
	 arr[i]=s.nextInt();
	 PriorityQueue<Long> q=new PriorityQueue<>();
	 long sum=0;
	 for(int i=0;i<n;i++)
	 {
	     int t=s.nextInt();
	     q.add(arr[i]+sum);
	     sum+=t;
	     long res=0;
	     while(!q.isEmpty()&&q.peek()<=sum)
	     {
	         res+=q.remove()-sum+t;
	     }
	     System.out.print(res+(long)t*q.size()+" ");

	 }

	}

}


import java.io.*;

import java.lang.reflect.Array;
import java.util.*;

public class Template {

    long MODULO = 1L * 1000 * 1000 * 1000 * 1000 * 1000 ;
    long b = 31;
    String fileName = "";
    void solve() throws IOException {
        int n = readInt();
        int[] v = new int[n+1];
        int[] t = new int[n+1];
        for(int i=1; i<=n; ++i){
            v[i] = readInt();
        }
        for(int i=1; i<=n; ++i){
            t[i] = readInt();
        }
        long[] prefs = new long[n+1];
        prefs[0] = t[0];
        for(int i=1; i<=n; ++i){
            prefs[i] = prefs[i-1] + t[i];
        }

        SegmentTree sgt = new SegmentTree(n + 1);
        long[] ans = new long[n+1];
        for(int i=1; i<=n; ++i){
            int curV = v[i];
            int l = i-1;
            int r = n + 1;
            while(r-l>1){
                int mid = (r+l)/2;
                if(prefs[mid] - prefs[i-1] >= curV){
                    r = mid;
                }else{
                    l = mid;
                }
            }
            //out.println(i +" " + l);
            if(l != i - 1) sgt.update(1, 1, n, i, l, 1);
            if(l+1<n+1) ans[l+1] += v[i] - (prefs[l] - prefs[i-1]);
            //out.println(sgt.get(1, 1, n, i));
        }
        for(int i=1; i<=n; ++i){
            out.print(1L*t[i]*sgt.get(1, 1, n, i)+ans[i]+" ");
        }
    }

    boolean isLower(char c){
        return c >= 'a' && c <= 'z';
    }

    ////////////////////////////////////////////////////////////
    class Pair implements Comparable<Pair>{
        int ind,val;
        Pair(int a, int b){
            this.ind = a;
            this.val = b;
        }

        @Override
        public int compareTo(Pair o) {
            return this.val - o.val;
        }
    }
    class SegmentTree{
        int[] t;
        int n;
        SegmentTree(int n){
            t = new int[4*n];
            build(new int[n+1], 1, 1, n);
        }
        void build (int a[], int v, int tl, int tr) {
            if (tl == tr)
                t[v] = a[tl];
            else {
                int tm = (tl + tr) / 2;
                build (a, v*2, tl, tm);
                build (a, v*2+1, tm+1, tr);
            }
        }

        void update (int v, int tl, int tr, int l, int r, int add) {
            if (l > r)
                return;
            if (l == tl && tr == r)
                t[v] += add;
            else {
                int tm = (tl + tr) / 2;
                update (v*2, tl, tm, l, Math.min(r,tm), add);
                update (v*2+1, tm+1, tr, Math.max(l,tm+1), r, add);
            }
        }

        int get (int v, int tl, int tr, int pos) {
            if (tl == tr)
                return t[v];
            int tm = (tl + tr) / 2;
            if (pos <= tm)
                return t[v] + get (v*2, tl, tm, pos);
            else
                return t[v] + get (v*2+1, tm+1, tr, pos);
        }
    }
    class Fenwik {
        long[] t;
        int length;

        Fenwik(int[] a) {
            length = a.length + 100;
            t = new long[length];

            for (int i = 0; i < a.length; ++i) {
                inc(i, a[i]);
            }
        }

        void inc(int ind, int delta) {
            for (; ind < length; ind = ind | (ind + 1)) {
                t[ind] += delta;
            }
        }

        long getSum(int r) {
            long sum = 0;
            for (; r >= 0; r = (r & (r + 1)) - 1) {
                sum += t[r];
            }
            return sum;
        }
    }
    int gcd(int a, int b){
        return b == 0 ? a : gcd(b, a%b);
    }

    long binPow(long a, long b, long m) {
        if (b == 0) {
            return 1;
        }
        if (b % 2 == 1) {
            return ((a % m) * (binPow(a, b - 1, m) % m)) % m;
        } else {
            long c = binPow(a, b / 2, m);
            return (c * c) % m;
        }

    }

    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        new Template().run();
    }

    void run() throws NumberFormatException, IOException {
        solve();
        out.close();
    };

    BufferedReader in;
    PrintWriter out;

    StringTokenizer tok;
    String delim = " ";
    Random rnd = new Random();

    Template() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(System.out);
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }

        }
        tok = new StringTokenizer("");
    }

    String readLine() throws IOException {
        return in.readLine();
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            String nextLine = readLine();
            if (null == nextLine) {
                return null;
            }

            tok = new StringTokenizer(nextLine);
        }
        return tok.nextToken();
    }

    int readInt() throws NumberFormatException, IOException {
        return Integer.parseInt(readString());
    }
    byte readByte() throws NumberFormatException, IOException {
        return Byte.parseByte(readString());
    }
    int[] readIntArray (int n) throws NumberFormatException, IOException {
        int[] a = new int[n];
        for(int i=0; i<n; ++i){
            a[i] = readInt();
        }
        return a;
    }
    long readLong() throws NumberFormatException, IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(readString());
    }
}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.TreeSet;

public final class CF_VK_2018_R1_B{

	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}

	//static long mod=1000000007;
	static long mod=998244353;
	static long MX=1000000000000000001L;

	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x;
	}

	static int MAX;

	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader=new InputReader(System.in);

		int n=reader.readInt();
		long[] V=new long[n];
		long[] T=new long[n];
		for (int i=0;i<n;i++)
			V[i]=reader.readInt();

		long[] sum=new long[n];
		long[] rem=new long[n+1];
		long cur=0;
		for (int i=0;i<n;i++) {
			T[i]=reader.readInt();
			cur+=T[i];
			sum[i]=cur;

		}
		//log(sum);
		long[] diff=new long[n+1];
		for (int i=0;i<n;i++){
			//log("------   "+V[i]);
			long base=0;
			if (i>0)
				base=sum[i-1];
			long target=base+V[i];
			//log("base:"+base);
			int idx=Arrays.binarySearch(sum,i,n,target);

			/*
			if (idx<0)
				idx=-idx-2;
			log("i:"+i+" idx:"+idx);
			for (int u=i;u<=idx;u++){
				rem[u]+=T[u];
				V[i]-=T[u];
				logWln(T[u]+" ");
			}
			rem[idx+1]=V[i];
			log(V[i]);

			 */

			if (idx<0)
				idx=-idx-2;
			if (idx>=0){
				diff[i]++;
				diff[idx+1]--;
				rem[idx+1]+=target-sum[idx];

			} else
				rem[i]+=V[i];
			//log("i:"+i+" idx:"+idx+" rem:"+rem);

		}

		long[] ans=new long[n];
		long st=0;
		for (int i=0;i<n;i++){
			st+=diff[i];
			ans[i]=st*T[i]+rem[i];
		}

		for (int i=0;i<n;i++){
			outputWln(ans[i]+" ");
		}
		output("");

		try {
			out.close();
		}
		catch (Exception EX){}

	}

	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res=new StringBuilder();
			do {
				res.append((char)c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}


import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.TreeSet;

public final class CF_VK_2018_R1_B{

	static boolean verb=true;
	static void log(Object X){if (verb) System.err.println(X);}
	static void log(Object[] X){if (verb) {for (Object U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X){if (verb) {for (int U:X) System.err.print(U+" ");System.err.println("");}}
	static void log(int[] X,int L){if (verb) {for (int i=0;i<L;i++) System.err.print(X[i]+" ");System.err.println("");}}
	static void log(long[] X){if (verb) {for (long U:X) System.err.print(U+" ");System.err.println("");}}

	static void logWln(Object X){if (verb) System.err.print(X);}
	static void info(Object o){	System.out.println(o);}
	static void output(Object o){outputWln(""+o+"\n");	}
	static void outputWln(Object o){try {out.write(""+ o);} catch (Exception e) {}}

	//static long mod=1000000007;
	static long mod=998244353;
	static long MX=1000000000000000001L;

	// Global vars
	static BufferedWriter out;
	static InputReader reader;

	static long powerMod(long b,long e,long m){
		long x=1;
		while (e>0) {
			if (e%2==1)
				x=(b*x)%m;
			b=(b*b)%m;
			e=e/2;
		}
		return x;
	}

	static int MAX;

	static void process() throws Exception {

		out = new BufferedWriter(new OutputStreamWriter(System.out));
		reader=new InputReader(System.in);

		int n=reader.readInt();
		long[] V=new long[n];
		long[] T=new long[n];
		for (int i=0;i<n;i++)
			V[i]=reader.readInt();

		long[] sum=new long[n];
		long[] rem=new long[n+1];
		long cur=0;
		for (int i=0;i<n;i++) {
			T[i]=reader.readInt();
			cur+=T[i];
			sum[i]=cur;

		}
		//log(sum);
		long[] diff=new long[n+1];
		for (int i=0;i<n;i++){
			//log("------   "+V[i]);
			long base=0;
			if (i>0)
				base=sum[i-1];
			long target=base+V[i];
			//log("base:"+base);
			int idx=Arrays.binarySearch(sum,target);

			/*
			if (idx<0)
				idx=-idx-2;
			log("i:"+i+" idx:"+idx);
			for (int u=i;u<=idx;u++){
				rem[u]+=T[u];
				V[i]-=T[u];
				logWln(T[u]+" ");
			}
			rem[idx+1]=V[i];
			log(V[i]);

			 */

			if (idx<0)
				idx=-idx-2;
			if (idx>=0){
				diff[i]++;
				diff[idx+1]--;
				rem[idx+1]+=target-sum[idx];

			} else
				rem[i]+=V[i];
			//log("i:"+i+" idx:"+idx+" rem:"+rem);

		}

		long[] ans=new long[n];
		long st=0;
		for (int i=0;i<n;i++){
			st+=diff[i];
			ans[i]=st*T[i]+rem[i];
		}

		for (int i=0;i<n;i++){
			outputWln(ans[i]+" ");
		}
		output("");

		try {
			out.close();
		}
		catch (Exception EX){}

	}

	public static void main(String[] args) throws Exception {
		process();

	}

	static final class InputReader {
		private final InputStream stream;
		private final byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		private int read() throws IOException {
			if (curChar >= numChars) {
				curChar = 0;
				numChars = stream.read(buf);
				if (numChars <= 0) {
					return -1;
				}
			}
			return buf[curChar++];
		}

		public final String readString() throws IOException {
			int c = read();
			while (isSpaceChar(c)) {
				c = read();
			}
			StringBuilder res=new StringBuilder();
			do {
				res.append((char)c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public final int readInt() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		public final long readLong() throws IOException {
			int c = read();
			boolean neg=false;
			while (isSpaceChar(c)) {
				c = read();
			}
			char d=(char)c;
			//log("d:"+d);
			if (d=='-') {
				neg=true;
				c = read();
			}
			long res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			//log("res:"+res);
			if (neg)
				return -res;
			return res;

		}

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	}

}


import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException{
        Scan sc = new Scan();
        int n = sc.scanInt();
        Sol sol = new Sol(n);
        for(int i = 1; i <= n; ++i)
            sol.addV(i, sc.scanInt());

        for(int i = 1; i <= n; ++i)
            sol.addT(i, sc.scanInt());

        sol.solve();
    }
}

class Sol {
    int[] V,T,cumS;
    ArrayList<Integer>[] last;
    int n;

    Sol(int n){
        this.n = n;
        V = new int[n+1];
        T = new int[n+1];
        cumS = new int[n+1];
        last = new ArrayList[n+1];
    }

    void addV(int i, int val){
        V[i] = val;
    }

    void addT(int i, int val){
        T[i] = val;
        cumS[i] = (cumS[i-1]+val);
    }

    void fillcumS(){
       // System.out.println(Arrays.toString(cumS));
        for(int i = 1; i <= n; ++i){
            int pos = bS(i, n+1, V[i]+cumS[i-1]);
            //System.out.print(i + " " + pos + " " + V[i] + ", " );
            if(pos <= n){
                if(last[pos] == null)
                    last[pos] = new ArrayList<Integer>();
                last[pos].add(i);
            }
        }
    }

    int bS(int l, int h, int key){
        while(l < h){
            int mid = (l+h)/2;
            if(cumS[mid] >= key)
                h = mid;
            else
                l = mid + 1;
        }
        return l;
    }

    void solve(){
        fillcumS();
        int curr = 0;
        for(int i = 1; i <= n; ++i){
            ++curr;
            int res = curr*T[i];
            if(last[i] != null){
                for(int j : last[i]){
                    res -= (cumS[i] - V[j] - cumS[j-1]);
                    curr-=1;
                }
            }
           System.out.print(res + " ");
        }
    }
}

class Scan
{
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;
    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
        throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
            return -1;
        }
        return buf[index++];
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    private boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
        return true;
        return false;
    }
}


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

int main() {
}


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

int main() {
    int N;
    cin >> N;
    int winrar, winC =0, winC2 =0;
    for(int i =0; i < N; i++) {
        int p;
        cin >> p;
        if(winC < p) winC2 =winC, winC =p;
        else if(winC2 < p) winC2 =p;
        if(winC == p) winrar =i;}
    cout << winrar+1 << " " << winC2 << "\n";
    return 0;}


#include <cstdio>
#include <vector>
#include <algorithm>

int main(){

    int n(0); scanf("%d", &n);
    std::vector<std::pair<int,int>> bids(n, std::pair<int,int>(0,0));

    int temp(0);
    for(int k = 0; k < n; k++){scanf("%d", &temp); bids[k] = std::pair<int,int>(temp,k);}
    std::sort(bids.begin(), bids.end());
    printf("%d %d\n", 1 + bids[n - 1].second, bids[n - 2].first);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int N,i,x;
pair<int,int> p[2];
main()
{
    cin>>N;
    for(i=1;i<=N;i++)
    {
        cin>>x;
        if(x>p[1].first)p[1].first=x,p[1].second=i;
        if(p[0]<p[1])swap(p[0],p[1]);
    }
    cout<<p[0].second<<" "<<p[1].first;
}


#include <algorithm>
#include <iostream>
#include <iterator>
#include <cassert>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <complex>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
#include <bitset>
#include <stack>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <set>
#include <map>
//#include <unordered_map>

#define 	ll long long
#define 	lld long long int
#define 	sc scanf
#define 	pi 2*acos(0.0)
#define 	f first
#define 	s second
#define 	sz size()
#define 	mp make_pair
#define 	maxall(v) *max_element(v.begin(),v.end())
#define 	minall(v) *min_element(v.begin(),v.end())
#define 	Sort(v) sort(v.begin(),v.end())
#define 	clr(a)  memset(a,0,sizeof(a))
#define 	pb push_back
#define 	inf 1000000000
#define 	mod 1000000009
using namespace std;
//unordered_map<int,int> unmap;
int main(){
	int n,dat;
	sc("%d",&n);
	vector<int> vec;
	for (int i = 0; i < n; ++i)
	{
		sc("%d",&dat);
		vec.pb(dat);
	}
	int ma=-1,po=0;
	for (int i = 0; i < n; ++i){
		if(ma < vec[i]){
			ma=vec[i];
			po=i+1;
		}
	}
	sort(vec.begin(),vec.end());
	printf("%d %d\n",po,vec[vec.size()-2]);

	return 0;
}


#include <algorithm>
#include <cstdio>
#include <vector>

int main() {
	int n;
	scanf("%d", &n);
	std::vector<std::pair<int, int> > v;
	for(int i = 0; i < n; i++) {
		int t;
		scanf("%d", &t);
		v.push_back(std::make_pair(t, i));
	}
	std::sort(v.begin(), v.end());
	printf("%d %d\n", v[v.size()-1].second+1, v[v.size()-2].first);
	return 0;
}


#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;

#ifndef ONLINE_JUDGE
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }
typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
	template<class S,class T>
	ostream &operator <<(ostream& out,const pair<S,T>& a){
		out<<'('<<a.fr<<','<<a.sc<<')';
		return out;
	}
}

lint readL(){
	lint res;
#ifdef ONLINE_JUDGE
	scanf("%I64d",&res);
#else
	scanf("%lld",&res);
#endif
	return res;
}
void printL(lint res){
#ifdef ONLINE_JUDGE
	printf("%I64d",res);
#else
	printf("%lld",res);
#endif
}

//const int INF=5e8;

int n;
pi ar[1005];
int main(){
	cin>>n;
	REP(i,n) cin>>ar[i].fr,ar[i].sc=i;
	sort(ar,ar+n,greater<pi>());
	printf("%d %d\n",ar[0].sc+1,ar[1].fr);

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <queue>
#include <functional>
#include <string>
using namespace std;
int n;
int main(){
  cin>>n;
  vector<int> prices(n, 0), indexes;
  for_each(prices.begin(), prices.end(), [](int & x){int a; cin>>a; x = a;});
  indexes = prices;
  sort(prices.begin(), prices.end());
  int res = prices[n - 2];
  for(int i = 0; i < n; ++i){
    if(indexes[i] == prices[n - 1]){
      cout<<i + 1<<" "<<res<<endl;
      return 0;
    }
  }
}


#include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define repf(i, b) for (int i = 0; i < b; i++)

#define all_of(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define fi first
#define se second

#define y0 y0___
#define y1 y1___

typedef long long ll;
typedef long double ld;

typedef vector<int> ivect;
typedef vector<vector<int>> ivect2d;
typedef pair<int, int> ipair;

template <typename T>
istream& operator>>(istream& in, vector<T>& arr) {
    for (T& i: arr) {
        in >> i;
    }

    return in;
}

template <typename T>
ostream& operator<<(ostream& out, vector<vector<T>>& arr) {
    for (vector<T>& i: arr) {
        out << i;
    }

    out << endl;

    return out;
}

template <typename T>
ostream& operator<<(ostream& out, vector<T>& arr) {
    for (T& i: arr) {
        out << i << ' ';
    }

    out << endl;

    return out;
}

int main() {

    int n;
    cin >> n;

    vector<ipair> arr(n);
    repf(i, n) {
        cin >> arr[i].fi;
        arr[i].se = i;
    }

    sort(all_of(arr));

    cout << (arr[arr.size() - 1].se + 1) << ' ' << arr[arr.size() - 2].fi;

}


#include <cstdio>
#include <algorithm>
int N;
struct st
{
	int x,p;
	bool operator <(const st&B) const {return x<B.x;}
} a[10005];
int main()
{
	scanf("%d",&N);
	for (int i=1; i<=N; i++) scanf("%d",&a[i].x),a[i].p=i;
	std::sort(a+1,a+N+1);
	printf("%d %d\n",a[N].p,a[N-1].x);
}


#include <iostream>
#include <string>

void SecondPriceAuction(int psize,int p[]);

void mainSecondPriceAuction();

int main()
{

    mainSecondPriceAuction();

    return 0;
}

void SecondPriceAuction(int psize, int p[])
{
    int tmp = 0;
    int  tmp2 = 0;
    int indextmp = 0;

    for (int i = 0; i < psize; i++)
    {
        if (p[i]>tmp)
        {
            tmp2 = tmp;
            tmp = p[i];
            indextmp = i + 1;

        }

    }

    cout << indextmp << " " << tmp2;
}

void mainSecondPriceAuction()
{
    int vsize;

    cin >> vsize;

    int arry[1001];
    for (int i = 0; i < vsize; i++)
    {
        cin >> arry[i];
    }

    SecondPriceAuction(vsize,arry);

}


#include <iostream>
#include <string>

using namespace std;

string SecondPriceAuction(int psize,int p[]);

void mainSecondPriceAuction();

int main()
{

    mainSecondPriceAuction();

    return 0;
}

string SecondPriceAuction(int psize, int p[])
{
    int tmp = 0;
    int  tmp2 = 0;
    int indextmp = 0;

    for (int i = 0; i < psize; i++)
    {
        if (p[i]>tmp)
        {
            tmp2 = tmp;
            tmp = p[i];
            indextmp = i + 1;

        }

    }

    return "" + to_string(indextmp) + " " + to_string(tmp2);
}

void mainSecondPriceAuction()
{
    int vsize;

    cin >> vsize;

    int arry[1001];
    for (int i = 0; i < vsize; i++)
    {
        cin >> arry[i];
    }

    cout << SecondPriceAuction(vsize,arry);

}


#include <iostream>
#include <string>
#include <sstream>

void SecondPriceAuction(int psize,int p[]);

void mainSecondPriceAuction();

int main()
{

    mainSecondPriceAuction();

    return 0;
}

void SecondPriceAuction(int psize, int p[])
{
    int tmp = 0;
    int  tmp2 = 0;
    int indextmp = 0;

    for (int i = 0; i < psize; i++)
    {
        if (p[i]>tmp)
        {
            tmp2 = tmp;
            tmp = p[i];
            indextmp = i + 1;

        }

    }

    cout << indextmp << " " << tmp2;
}

void mainSecondPriceAuction()
{
    int vsize;

    cin >> vsize;

    int arry[1001];
    for (int i = 0; i < vsize; i++)
    {
        cin >> arry[i];
    }

    SecondPriceAuction(vsize,arry);

}


#include <iostream>
#include <string>
#include <sstream>
#include <map>

using namespace std;

void SecondPriceAuction(int psize, int p[]);

void mainSecondPriceAuction();

int main()
{

    mainSecondPriceAuction();

    return 0;
}

void SecondPriceAuction(int psize, int p[])
{
    int tmp = 0;
    int  tmp2 = 0;
    int indextmp = 0;

    for (int i = 0; i < psize; i++)
    {
        if (p[i]>tmp)
        {
            tmp2 = tmp;
            tmp = p[i];
            indextmp = i + 1;

        }
        else{
            if (p[i] > tmp2)
            {
                tmp2 = p[i];
            }
        }

    }

    std::cout << indextmp << " " << tmp2;
    //return "" + to_string(indextmp) + " " + to_string(tmp2);
}

void mainSecondPriceAuction()
{

        int vsize;

        cin >> vsize;

        int arry[1001];
        for (int i = 0; i < vsize; i++)
        {
            cin >> arry[i];
        }
        SecondPriceAuction(vsize, arry);
        //cout << SecondPriceAuction(vsize,arry);

}


#include <iostream>
#include <string>
#include <sstream>
#include <map>

using namespace std;

void SecondPriceAuction(int psize, int p[]);

void mainSecondPriceAuction();

int main()
{

    mainSecondPriceAuction();

    return 0;
}

void SecondPriceAuction(int psize, int p[])
{
    int tmp = 0;
    int  tmp2 = 0;
    int indextmp = 0;

    for (int i = 0; i < psize; i++)
    {
        if (p[i]>tmp)
        {
            tmp2 = tmp;
            tmp = p[i];
            indextmp = i + 1;

        }

    }

    std::cout << indextmp << " " << tmp2;
    //return "" + to_string(indextmp) + " " + to_string(tmp2);
}

void mainSecondPriceAuction()
{
    int vsize;

    cin >> vsize;

    int arry[1001];
    for (int i = 0; i < vsize; i++)
    {
        cin >> arry[i];
    }
    SecondPriceAuction(vsize, arry);
    //cout << SecondPriceAuction(vsize,arry);

}


#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

std::pair<int, int> a[1010];

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  //std::ios::sync_with_stdio(0);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  std::sort(a + 1, a + n + 1);
  printf("%d %d", a[n].second, a[n - 1].first);
}


//Program: a
//Author: gary
//Date: 16/01/2014
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ( (int) (x).size() )
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef pair<int, int> i2;
const int INF = 1e9;
const int MAX_N = 1111;

int main(){
  ios::sync_with_stdio(0);
  int n, a[MAX_N], o[MAX_N];
  while(cin >> n){
    for(int i = 0; i < n; i++){
      cin >> a[i];
      o[i] = i;
    }
    sort(o, o + n, [&]
	 (const int& i, const int& j) -> bool {
	   return a[i] > a[j];
	 });
    printf("%d %d\n", o[0] + 1, a[o[1]]);
  }
  return 0;
}


#include <iostream>
#include <sstream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <numeric>
#include <utility>
#include <functional>
#include <algorithm>
#include <complex>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cctype>
#include <cstring>
using namespace std;

#define FOREACH(M_i, M_c)	for(auto M_i = (M_c).begin(); M_i != (M_c).end(); ++M_i)
#define EXIST(M_c, M_v)	((M_c).find((M_v)) != (M_c).end())
#define SORT(M_c)			sort((M_c).begin(), (M_c).end())
#define FOR(M_i, M_from, M_to)	for(int M_i = (M_from); M_i < (M_to); ++M_i)
#define REP(M_i, M_n)				FOR(M_i, 0, M_n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

template<typename T>
void read(istream& in, vector<T>& list, size_t n)
{
	for(size_t i = 0; i < n; ++i)
	{
		T value;
		in >> value;
		list.push_back(value);
	}
};
template<typename T, typename INDEX_T = int>
struct indexed_value
{
	typedef T		value_t;
	typedef INDEX_T	index_t;

	value_t value;
	index_t index;
};
template<typename T>
void read(istream& in, vector<indexed_value<T> >& list, size_t n)
{
	for(size_t i = 0; i < n; ++i)
	{
		indexed_value<T> v;
		in >> v.value;
		v.index = i;
		list.push_back(v);
	}
}
template<typename FORWARD_ITE>
void write(ostream& out, FORWARD_ITE first, FORWARD_ITE last, const string& sep = " ")
{
	if(first != last) { out << *first; ++first; }
	while(first != last)
	{
		out << sep << *first;
		++first;
	}
}

struct problem_t
{
	int n;
	vector<indexed_value<int> > list;
	friend istream& operator >>(istream& in, problem_t& o)
	{
		in >> o.n;
		read(in, o.list, o.n);
		return in;
	}
	friend ostream& operator <<(ostream& out, const problem_t& o)
	{
		out << o.n << endl;
		for(size_t i = 0; i < o.list.size(); ++i)
		{
			if(i > 0) { out << " "; }
			out << o.list[i].value;
		}
		return out;
	}
};
void solve(problem_t& p, ostream& out)
{
	vector<indexed_value<int> >& list = p.list;
	sort(list.begin(), list.end(), [](indexed_value<int>&left, indexed_value<int>&right) { return left.value < right.value; });
	out << list.back().index + 1 << " " << list[list.size() - 2].value;
}
#ifdef DO_TEST
typedef shared_ptr<problem_t> problem_sptr_t;
void write(ostream& out, const problem_sptr_t& p) { out << *p; }
void read(istream& in, problem_sptr_t& p) { in >> *p; }
problem_sptr_t create_problem(const string& input)
{
	shared_ptr<problem_t> p = make_shared<problem_t>();
	stringstream s;
	s << input;
	s >> *p;
	return p;
}
void solve(problem_sptr_t p, ostream& out)
{
	solve(*p, out);
}
#else
int main(int argc, char* argv[])
{
	problem_t p;
	cin >> p;
	solve(p, cout);
	return 0;
}
#endif


#include <iostream>
#include <sstream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <numeric>
#include <utility>
#include <functional>
#include <algorithm>
#include <complex>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cctype>
#include <cstring>
using namespace std;

#define FOREACH(M_i, M_c)	for(auto M_i = (M_c).begin(); M_i != (M_c).end(); ++M_i)
#define EXIST(M_c, M_v)	((M_c).find((M_v)) != (M_c).end())
#define SORT(M_c)			sort((M_c).begin(), (M_c).end())
#define FOR(M_i, M_from, M_to)	for(int M_i = (M_from); M_i < (M_to); ++M_i)
#define REP(M_i, M_n)				FOR(M_i, 0, M_n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

template<typename T>
void read(istream& in, vector<T>& list, size_t n)
{
	for(size_t i = 0; i < n; ++i)
	{
		T value;
		in >> value;
		list.push_back(value);
	}
};
template<typename T, typename INDEX_T = int>
struct indexed_value
{
	typedef T		value_t;
	typedef INDEX_T	index_t;

	value_t value;
	index_t index;
};
template<typename T>
void read(istream& in, vector<indexed_value<T> >& list, size_t n)
{
	for(size_t i = 0; i < n; ++i)
	{
		indexed_value<T> v;
		in >> v.value;
		v.index = i;
		list.push_back(v);
	}
}
template<typename FORWARD_ITE>
void write(ostream& out, FORWARD_ITE first, FORWARD_ITE last, const string& sep = " ")
{
	if(first != last) { out << *first; ++first; }
	while(first != last)
	{
		out << sep << *first;
		++first;
	}
}

struct problem_t
{
	int n;
	vector<indexed_value<int> > list;
	friend istream& operator >>(istream& in, problem_t& o)
	{
		in >> o.n;
		read(in, o.list, o.n);
		return in;
	}
	friend ostream& operator <<(ostream& out, const problem_t& o)
	{
		out << o.n << endl;
		for(size_t i = 0; i < o.list.size(); ++i)
		{
			if(i > 0) { out << " "; }
			out << o.list[i].value;
		}
		return out;
	}
};
void solve(problem_t& p, ostream& out)
{
	vector<indexed_value<int> >& list = p.list;
	sort(list.begin(), list.end(), [](const indexed_value<int>&left, const indexed_value<int>&right) { return left.value < right.value; });
	out << list.back().index + 1 << " " << list[list.size() - 2].value;
}
#ifdef DO_TEST
typedef shared_ptr<problem_t> problem_sptr_t;
void write(ostream& out, const problem_sptr_t& p) { out << *p; }
void read(istream& in, problem_sptr_t& p) { in >> *p; }
problem_sptr_t create_problem(const string& input)
{
	shared_ptr<problem_t> p = make_shared<problem_t>();
	stringstream s;
	s << input;
	s >> *p;
	return p;
}
void solve(problem_sptr_t p, ostream& out)
{
	solve(*p, out);
}
#else
int main(int argc, char* argv[])
{
	problem_t p;
	cin >> p;
	solve(p, cout);
	return 0;
}
#endif


// .... .... .....!
// ...... ......!
// .... ....... ..... ..!

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <cassert>

#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <numeric>
#include <bitset>

#include <cstdio>
#include <cstring>

using namespace std;

#define rep(i, n) for (int i = 0, _n = (int)(n); i < _n; i++)
#define fer(i, x, n) for (int i = (int)(x), _n = (int)(n); i < _n; i++)
#define rof(i, n, x) for (int i = (int)(n), _x = (int)(x); i-- > _x; )
#define fch(i, x) for (__typeof(x.begin()) i = x.begin(); i != x.end(); i++)
#define sz(x) (int((x).size()))
#define pb push_back
#define mkp make_pair
#define all(X) (X).begin(),(X).end()

#define X first
#define Y second

template<class T> inline void smin(T &a, T b){if(b<a)a=b;}
template<class T> inline void smax(T &a, T b){if(a<b)a=b;}

typedef long long ll;
typedef pair<int, int> pii;

////////////////////////////////////////////////////////////////////////////////

const int maxn = 1000 + 100;

int n;
pii p[maxn];

int main()
{
	ios_base::sync_with_stdio (false);

	cin >> n;
	rep (i, n) cin >> p[i].X, p[i].Y = i;
	sort (p, p+n);
	reverse (p, p+n);
	cout << p[0].Y+1 << ' ' << p[1].X << endl;

	{ return 0; }
}


using namespace std;

#include "bits/stdc++.h"

#define FORi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORn(i, n) FORi(i, 0, n)

vector< int > a;
vector< int > p;

int main()
{
    int N;

    scanf("%d", &N);

    a.assign(N, 0);
    p.assign(N, 0);

    for (int &x : a) scanf("%d", &x);
    FORn(i, N) p[i] = i;

    sort( begin(p), end(p), [](int x, int y) -> bool
    {
        return a[x] > a[y];
    } );

    printf("%d %d\n", p[0]+1, a[ p[1] ]);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using std::vector;
using std::cin;
using std::cout;
using std::endl;
using std::sort;

int main (int argc, char * argv[]) {
  int n;
  vector<int> p;
  vector<int> k;

  cin >> n;
  p.resize(n);
  k.resize(n);

  for (int i = 0; i < n; ++i) {
    k.at(i) = i;
    cin >> p.at(i);
  }

  sort(k.begin(), k.end(), [&p](int i1, int i2) {
    return p.at(i1) < p.at(i2);
  });

  int winner = k.at(k.size() - 1);
  int cost = p.at(k.at(k.size() - 2));

  cout << (1 + winner) << " " << cost << endl;

  return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int i,a[2000],n,x,sum;
    cin>>n;
    sum=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>sum)
        {
            sum=a[i];
            x=i;
        }
    }

    sort(a,a+n);
    cout<<x+1<<' '<<a[n-2]<<endl;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int i,a[2000],n;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<n<<' '<<a[n-2]<<endl;
    return 0;
}


//
// a.cpp
//
// Siwakorn Srisakaokul - ping128
// Written on Thursday, 16 January 2014.
//

#include <cstdio>
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <algorithm>
#include <map>
#include <ctype.h>
#include <string.h>

#include <assert.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<PII, int> PII2;

PII in[1005];

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> in[i].first;
        in[i].second = i + 1;
    }

    sort(in, in + N);
    printf("%d %d\n", in[N - 1].second, in[N - 2].first);

    return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <complex>
#include <iostream>
#include <algorithm>

#include <ctime>
#include <deque>
#include <bitset>
#include <cctype>
#include <utility>
#include <cassert>
using namespace std;

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

int a[1011];

int main() {
    ios :: sync_with_stdio(false); cin.tie(NULL);
    cout << (fixed) << setprecision(6);
    int n;
    while (cin >> n) {
        FOR(i,1,n) cin >> a[i];
        int id = max_element(a+1, a+n+1) - a;
        int best1 = *max_element(a+1, a+n+1);
        a[id] = -1;
        int best2 = *max_element(a+1, a+n+1);
        cout << id << ' ' << best2 << endl;
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>
#include <stack>
#define File_in(input) freopen(input, "r", stdin)
#define File_out(output) freopen(output, "w", stdout)
#define FOR(i,b,n) for(int i=b; i<=n; i++)
#define RFOR(i,n,b) for(int i=n; i>=b; i--)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> point;

void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T)
{
  cerr << H << ' ';
  dout(T...);
}

int main ()
{
    int n,x,y;
    vector <int> a;
    cin >> n;
    while (n--)
        cin >> x, a.push_back(x);
    n = a.size();
    x = 1;
    FOR(i,0,n-1)
    {
        if (a[i] > x)
        {
            x = a[i];
            y = i+1;
        }
    }
    sort(all(a));
    cout << y << ' ' << a[n-2] <<  ' ' << endl;
}


#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <stdio.h>
#include <stack>
#define File_in(input) freopen(input, "r", stdin)
#define File_out(output) freopen(output, "w", stdout)
#define FOR(i,b,n) for(int i=b; i<=n; i++)
#define RFOR(i,n,b) for(int i=n; i>=b; i--)
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int,int> point;

void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T)
{
  cerr << H << ' ';
  dout(T...);
}

int main ()
{
    int n,x1,y;
    vector <int> a;
    cin >> n;
    while (n--)
        cin >> x1, a.push_back(x1);
    n = a.size();
    x1 = 1;
    FOR(i,0,n-1)
    {
        if (a[i] > x1)
        {
            x1 = a[i];
            y = i+1;
        }
    }
    int x2 = 1;
    FOR(i,0,n-1)
    {
        if (a[i] > x2 && a[i]!= x1)
        {
            x2 = a[i];
        }
    }
    //sort(all(a));
    cout << y << ' ' << x2 <<  ' ' << endl;
}


#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <numeric>

using namespace std;

#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define SIZEOF(a) (sizeof(a)/sizeof((a)[0]))

const int MAX_N = 1e5+10;
pair<int, int> a[MAX_N];

int main()
{
    int n; cin >> n;
    FOR(i,n){
        int x; cin >> x;
        a[i] = make_pair(x, i+1);
    }
    sort(a, a+n);
    cout << a[n-1].second << " " << a[n-2].first << endl;
    return 0;
}


#include <stdio.h>
#include <cmath>

int main(){
    int n;
    scanf("%d" , &n);
    int a[1005]={};
    int x=0;
    int mai=1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d" , &a[i]);
        x=fmax(a[i],x);
        if(x==a[i])
            mai=i;
    }
    printf("%d " , mai);
    a[mai]=0;
    x=0;
    for(int i=1;i<=n;i++)
        x=fmax(a[i],x);
    printf("%d" , x);
    return 0;
}


#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
#include<list>
#include<map>
#include<vector>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
using namespace std;
#define Author "DemoVersion"
#define ull unsigned long long
const int inf ((1<<31)-1);
int dx[]={0,0,-1,1,1,-1,1,-1};
int dy[]={1,-1,0,0,1,1,-1,-1};
typedef pair<int,int> pii;
int main(){
    #ifdef _DEBUG
        freopen("in.txt","r",stdin);
    #endif
    pii bids[1047];
    int n,i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>bids[i].first;
        bids[i].second=i+1;
    }
    sort(bids,bids+n);
    cout<<bids[n-1].second<<" "<<bids[n-2].first;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stdlib.h>
#include <time.h>

using namespace std;

int n;
pair<int, int> p[1001];

int main() {

    //freopen("input.txt", "r", stdin);

    scanf("%d", &n);

    for(int i = 1;i <= n ;i++) {
        scanf("%d", &p[i].first);
        p[i].second = i;
    }

    sort(p, p + n + 1);

    printf("%d %d\n", p[n].second, p[n - 1].first);

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int INF=0x3f3f3f3f;

struct bid
{
    int id,v;
}B[1200];

bool cmp(bid a,bid b)
{
    return a.v>b.v;
}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&B[i].v),B[i].id=i;
    sort(B,B+n,cmp);
    printf("%d %d\n",B[0].id+1,B[1].v);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

const int maxn = 1000 + 10;
int p[maxn];
int n;

int main()
{
    cin>>n;
    for(int i = 0; i<n; i++)
        cin>>p[i];
    cout<<max_element(p, p + n) - p + 1<<" ";
    sort(p, p + n);
    reverse(p, p + n);
    cout<<p[1];

    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <bitset>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>

using namespace std;

const int INF = 1000 * 1000 * 1000;

#define DEBUG(x) cout << #x << " = " << x << endl;
#define ALL(v) v.begin(), v.end()
#define SZ(v) (int) v.size()

#define TASK ""

int main() {
	#ifdef EDDY
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#else
	//	freopen(TASK ".in", "r", stdin);
	//	freopen(TASK ".out", "w", stdout);
	#endif

	int N;

	cin >> N;

	vector<int> p(N);

	for (int i = 0; i < N; ++i) {
		cin >> p[i];
	}

	int mx = *max_element(ALL(p));

	for (int i = 0; i < N; ++i)
		if (p[i] == mx) {
			cout << i + 1 << " ";
			p[i] = -1;
			break;
		}

	mx = *max_element(ALL(p));

	cout << mx;

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,a[100],max=0,I,i,j,t,max2=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);

        if(a[i]>max){max=a[i];I=i;}
    }

    for(i=0;i<n;i++)
    {
        if(a[i]>max2 && a[i]!=max){max2=a[i];}
    }

    printf("%d %d",I+1,max2);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,a[100],max=0,I,i,j,t,max2=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);

        if(a[i]>max){max=a[i];I=i;}
        if(a[i]>max2 && a[i]!=max){max2=a[i];}
    }

    printf("%d %d",I+1,max2);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,a[100001],max=0,I,i,j,max2=0;

    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);

        if(a[i]>max){max=a[i];I=i;}
    }

    for(i=0;i<n;i++)
    {
        if(a[i]>max2 && a[i]!=max){max2=a[i];}
    }

    printf("%d %d",I+1,max2);
    return 0;
}


#include<stdio.h>
//#include<conio.h>
#include<stdlib.h>

int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}

int main()
{
    int n,i,j;
    int a[1000];
    scanf("%d",&n);
    int max = 0,index=0;
    for(i=0;i<n;i++)
    {
                    scanf("%d",&a[i]);
                    if(a[i]>max)
                    {
                    max = a[i];
                    index = i;
                    }
    }
    //printf("%d %d\n",max,index);

    qsort (a, n, sizeof(int), compare);
    /*for(j=0;j<n;j++)
    {
                     printf("%d\n",a[j]);
    }*/
    printf("%d %d",(index+1),a[n-2]);

    //getch();
    return 0;

}


#include<stdio.h>
void quick(int a[],int start,int end);
int main()
{
	int n,i,b=1,j;
	scanf("%d",&n);
	int a[n+1];
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);

	int 	max=a[1],temp,min;
	for(i=2;i<=n;i++)

		if(a[i]>max)
		{	max=a[i];
			b=i;
		}
	printf("%d ",b);
	for(i=1;i<n;i++)
{	min=i;
	for(j=i+1;j<=n;j++)
	{
		if(a[min]>a[j])
		{
			temp=a[min];
			a[min]=a[j];
			a[j]=temp;
		}

	}
}

//	quick(a,1,n);
	printf("%d\n",a[n-1]);

	return 0;
}

/*void quick(int a[],int start,int end)

  {

  if(start<end)

  {		int i,j,pivot=end,tmp;
  for(i=j=start;j<end;j++)
  {
  if(a[j-1]<a[pivot-1])

  {

  tmp=a[i-1];

  a[i-1]=a[j-1];

  a[j-1]=tmp;

  i++;

  }

  }

  tmp=a[pivot-1];

  a[pivot-1]=a[i-1];

  a[i-1]=tmp;

  quick(a,start,i-1);

  quick(a,i+1,end);

  }

  return;

  }*/


#include <stdio.h>

typedef struct {
    int id, p;
} Data;

Data data[ 1000 ];

int compare( const void *a, const void *b ) {
    return ( (Data *)b ) -> p - ( (Data *)a ) -> p;
}

int main( void ) {
    int i;
    int n, ans;

    scanf( "%d", &n );
    for ( i = 0; i < n; i++ ) {
        scanf( "%d", &data[ i ].p );
        data[ i ].id = i + 1;
    }

    qsort( data, n, sizeof(Data), &compare );

    printf( "%d %d\n", data[ 0 ].id, data[ 1 ].p );

    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,max,indmax;
    scanf("%d",&n);
    int tab[n];
    scanf("%d",&tab[0]);
    for (i=1;i<n;i++)
       scanf("%d",&tab[i]);
    indmax=0;
    max=tab[0];
     for (i=1;i<n;i++)
     {
         if (max <tab[i])
         {max=tab[i];
          indmax=i;}
     }
     max=0;
     for (i=0;i<n;i++)
     {
         if ((max <tab[i])&& (i!=indmax))
         {max=tab[i];
          }
     }
     printf("%d %d",indmax+1,max);
    return 0;