import java.util.*;
import java.io.*;
public class EdD {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		int t = Integer.parseInt(bf.readLine());
 		for(int i = 0;i<t;i++){
//	 		String input1 = bf.readLine().trim();
//	 		String input2 = bf.readLine().trim();
	 		StringTokenizer st = new StringTokenizer(bf.readLine());
	 		int n = Integer.parseInt(st.nextToken());
	 		int k = Integer.parseInt(st.nextToken());
	 		int[] x = new int[n];
	 		int[] y = new int[n];
	 		ArrayList<Integer> array = new ArrayList<Integer>();
	 		StringTokenizer st1 = new StringTokenizer(bf.readLine());
	 		StringTokenizer st2 = new StringTokenizer(bf.readLine());
	 		for(int j = 0;j<n;j++){
	 			x[j] = Integer.parseInt(st1.nextToken());
	 			array.add(x[j]);
	 		}
	 		for(int j =0;j<n;j++)
	 			y[j] = Integer.parseInt(st2.nextToken());
	 		Collections.sort(array);
	 		int maxsave = 1;
	 		int[] lefts = new int[n];
	 		int[] rights = new int[n];
	 		int prevl = 0;
	 		for(int j = 0;j<array.size()-1;j++){
	 			//
	 			int left = j-lowerBound(array, array.get(j)-k, 0, j+1)+1;
	 			lefts[j] = Math.max(prevl, left);
	 			prevl = lefts[j];
	 			int right = lowerBoundS(array, array.get(j+1)+k, j+1, array.size())-j;
	 			rights[j] = right;
	 		}
	 		for(int j = n-2;j>=0;j--)
	 			rights[j] = Math.max(rights[j+1], rights[j]);
	 		for(int j = 0;j<n-1;j++){
	 			maxsave = Math.max(maxsave,  lefts[j]+rights[j]);
	 		}
	 		out.println(maxsave);
 		}

 		out.println();

 		out.close();

 	}
	public static int lowerBound(ArrayList<Integer> array, int target, int l, int r){
		if (target <= array.get(0))
			return 0;
		int mid = -1;
		while (l<r){
			mid = (l+r)/2;
			if (array.get(mid)>= target && (mid-1< 0 || array.get(mid-1) < target))
				return mid;
			else if (array.get(mid) >= target)
				r = mid;
			else
				l = mid+1;
		}
		return mid;

	}
	//smallest index of integer greater than target
	public static int upperBound(ArrayList<Integer> array, int target, int l, int r){
		if (array.size() == 1)
			return 0;
		int mid = -1;
		while (l<r){
			mid = (l+r)/2;
			if (array.get(mid) > target && (mid-1 < 0 || array.get(mid-1) <= target))
				return mid;
			else if (array.get(mid) > target)
				r = mid;
			else
				l = mid+1;
		}
		return mid;

	}
	//last index of integer less than or equal to target
	public static int lowerBoundS(ArrayList<Integer> array, int target, int l, int r){
		if (target >= array.get(array.size()-1))
			return array.size()-1;
		int mid = -1;
		while (l<r){
			mid = (l+r)/2;
			if (array.get(mid)<= target && (mid + 1 >= array.size() || array.get(mid+1) > target))
				return mid;
			else if (array.get(mid) <= target)
				l = mid+1;
			else
				r = mid;
		}
		return mid;

	}
	//last index of integer less than target
		public static int upperBoundS(ArrayList<Integer> array, int target, int l, int r){
			if (array.size() == 1)
				return 0;
			int mid = -1;
			while (l<r){
				mid = (l+r)/2;
				if (array.get(mid)< target && (mid + 1 >= array.size() || array.get(mid+1) >= target))
					return mid;
				else if (array.get(mid) < target)
					l = mid+1;
				else
					r = mid;
			}
			return mid;

		}
}

//StringJoiner sj = new StringJoiner(" ");
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is


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

public class Main {
    static int[] x;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int T = sc.nextInt();
        for(int ti = 0; ti < T; ti++){
            int n = sc.nextInt();
            int k = sc.nextInt();
            x = sc.nextIntArray(n);
            int[] y = sc.nextIntArray(n);
            if(n < 2){
                pw.println(n);
                continue;
            }
            GeekInteger.save_sort(x);
            /*
            TreeMap<Integer,Integer> map = new TreeMap<>();
            for(int i = 0; i < n; i++){
                map.put(x[i],i);
            }
            int[] left = new int[n];
            int[] right = new int[n];
            for(int i = 0; i < n; i++){
                left[i] = map.get(map.ceilingKey(x[i]-k))-i+1;
                right[i] = map.get(map.floorKey(x[i]+k))-i+1;
                if(i > 0){
                    left[i] = Math.max(left[i],left[i-1]);
                }
            }
            */
            int[] left = new int[n];
            int[] right = new int[n];
            for(int i = 0; i < n; i++){
                left[i] = beamSearch(x[i]+k)-i+1;
                right[i] = (i+1)-beamSearchR(x[i]-k);
            }
            for(int i = n-1; i > 0; i--){
                left[i-1] = Math.max(left[i-1],left[i]);
            }
            for(int i = 0; i < n-1; i++){
                right[i+1] = Math.max(right[i+1],right[i]);
            }
            int ans = 0;
            for(int i = 1; i < n; i++){
                ans = Math.max(ans,left[i]+right[i-1]);
            }
            pw.println(ans);
        }
        pw.flush();
    }

    public static int beamSearch(int target){
        int left = 0;
        int right = x.length;
        while(right-left > 1){
            int mid = (left+right)/2;
            if(x[mid] > target){
                right = mid;
            }else{
                left = mid;
            }
        }
        return left;
    }

    public static int beamSearchR(int target){
        int left = -1;
        int right = x.length-1;
        while(right-left > 1){
            int mid = (left+right)/2;
            if(x[mid] < target){
                left = mid;
            }else{
                right = mid;
            }
        }
        return right;
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }

    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

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

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

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

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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


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

public class Main {
    static int[] x;
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        StringBuilder sb = new StringBuilder();
        int T = sc.nextInt();
        for(int ti = 0; ti < T; ti++){
            int n = sc.nextInt();
            int k = sc.nextInt();
            x = sc.nextIntArray(n);
            int[] y = sc.nextIntArray(n);
            if(n < 2){
                pw.println(n);
                continue;
            }
            GeekInteger.save_sort(x);
            /*
            TreeMap<Integer,Integer> map = new TreeMap<>();
            for(int i = 0; i < n; i++){
                map.put(x[i],i);
            }
            int[] left = new int[n];
            int[] right = new int[n];
            for(int i = 0; i < n; i++){
                left[i] = map.get(map.ceilingKey(x[i]-k))-i+1;
                right[i] = map.get(map.floorKey(x[i]+k))-i+1;
                if(i > 0){
                    left[i] = Math.max(left[i],left[i-1]);
                }
            }
            */
            int[] left = new int[n];
            int[] right = new int[n];
            for(int i = 0; i < n; i++){
                left[i] = beamSearch(x[i]+k)-i+1;
                right[i] = (i+1)-beamSearchR(x[i]-k);
                //pw.println(right[i]);
            }
            for(int i = n-1; i > 0; i--){
                left[i-1] = Math.max(left[i-1],left[i]);
            }
            for(int i = 0; i < n-1; i++){
                right[i+1] = Math.max(right[i+1],right[i]);
            }
            int ans = 0;
            for(int i = 0; i < n; i++){
                ans = Math.max(ans,left[i]+right[i]);
            }
            pw.println(Math.min(ans,n));
        }
        pw.flush();
    }

    public static int beamSearch(int target){
        int left = 0;
        int right = x.length;
        while(right-left > 1){
            int mid = (left+right)/2;
            if(x[mid] > target){
                right = mid;
            }else{
                left = mid;
            }
        }
        return left;
    }

    public static int beamSearchR(int target){
        int left = -1;
        int right = x.length-1;
        while(right-left > 1){
            int mid = (left+right)/2;
            if(x[mid] < target){
                left = mid;
            }else{
                right = mid;
            }
        }
        return right;
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }

    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

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

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

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

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

    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

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

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


// Main Code at the Bottom
import java.util.*;
import java.io.*;
public class Main{
	//Fast IO class
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else 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;
        }
    }
    static long MOD=1000000000+7;
    //debug
    static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    // Pair
    static class pair{
    	long x,y;
    	pair(long a,long b){
    		this.x=a;
    		this.y=b;
    	}
    	public boolean equals(Object obj) {
    		if(obj == null || obj.getClass()!= this.getClass()) return false;
            pair p = (pair) obj;
            return (this.x==p.x && this.y==p.y);
        }
    	public int hashCode() {
            return Objects.hash(x,y);
        }
    }
    static FastReader sc=new FastReader();
    static PrintWriter out=new PrintWriter(System.out);
    //Global variables and functions
    //Main function(The main code starts from here)
    public static void main (String[] args) throws java.lang.Exception {
    	int test=1;
    	test=sc.nextInt();
    	while(test-->0) {
    		int n=sc.nextInt();
    		long k=sc.nextLong();
    		Long a[]=new Long[n];
    		for(int i=0;i<n;i++) a[i]=sc.nextLong();
    		for(int i=0;i<n;i++) sc.nextInt();
    		Arrays.parallelSort(a);
    		//debug(a,k);
    		int dp[]=new int[n];
    		for(int i=0;i<n;i++) {
    			long x=a[i]+k;
    			int l=i,r=n-1,idx=i;
    			while(l<=r) {
    				int mid=l+(r-l)/2;
    				if(a[mid]<=x) {
    					idx=mid;
    					l=mid+1;
    				}
    				else r=mid-1;
    			}
    			dp[i]=idx;
    		}
    		//debug(dp);
    		long max[]=new long[n];
    		max[n-1]=dp[n-1]-n;
    		for(int i=n-2;i>=0;i--) max[i]=Math.max(max[i+1], dp[i]-i+1);
    		long ans=0;
    		for(int i=0;i<n;i++) {
    			ans=Math.max(ans, dp[i]-i+1+(dp[i]+1>=n?0:max[dp[i]+1]));
    		}
    		out.println(ans);
    	}
        out.flush();
        out.close();
    }
}


// Main Code at the Bottom
import java.util.*;
import java.io.*;
public class Main{
	//Fast IO class
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
        public FastReader() {
        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
        	if(!env) {
        		try {
					br=new BufferedReader(new FileReader("src\\input.txt"));
				} catch (FileNotFoundException e) {
					e.printStackTrace();
				}
        	}
        	else 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;
        }
    }
    static long MOD=1000000000+7;
    //debug
    static void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    // Pair
    static class pair{
    	long x,y;
    	pair(long a,long b){
    		this.x=a;
    		this.y=b;
    	}
    	public boolean equals(Object obj) {
    		if(obj == null || obj.getClass()!= this.getClass()) return false;
            pair p = (pair) obj;
            return (this.x==p.x && this.y==p.y);
        }
    	public int hashCode() {
            return Objects.hash(x,y);
        }
    }
    static FastReader sc=new FastReader();
    static PrintWriter out=new PrintWriter(System.out);
    //Global variables and functions
    //Main function(The main code starts from here)
    public static void main (String[] args) throws java.lang.Exception {
    	int test=1;
    	test=sc.nextInt();
    	while(test-->0) {
    		int n=sc.nextInt();
    		long k=sc.nextLong();
    		Long a[]=new Long[n];
    		for(int i=0;i<n;i++) a[i]=sc.nextLong();
    		for(int i=0;i<n;i++) sc.nextInt();
    		Arrays.parallelSort(a);
    		//debug(a);
    		int dp[]=new int[n];
    		for(int i=0;i<n;i++) {
    			long x=a[i]+k;
    			int l=i,r=n-1,idx=i;
    			while(l<=r) {
    				int mid=l+(r-l)/2;
    				if(a[mid]<=x) {
    					idx=mid;
    					l=mid+1;
    				}
    				else r=mid-1;
    			}
    			dp[i]=idx;
    		}
    		//debug(dp);
    		long max[]=new long[n];
    		max[n-1]=1;
    		for(int i=n-2;i>=0;i--) max[i]=Math.max(max[i+1], dp[i]-i+1);
    		long ans=0;
    		for(int i=0;i<n;i++) {
    			ans=Math.max(ans, dp[i]-i+1+(dp[i]+1>=n?0:max[dp[i]+1]));
    		}
    		out.println(ans);
    	}
        out.flush();
        out.close();
    }
}


import java.io.*;
import java.util.*;
public class E {

  public static void main(String[] args) {
      int t = sc.nextInt();
      while(t-- > 0)
        solve();
      out.close();
  }

  public static void sort(int[] a) {
  	int l = 0, r = a.length;
      ArrayList<Integer> list=new ArrayList<>();
      for (int i=l ; i<r; i++) list.add(a[i]);
      Collections.sort(list);
      for (int i=l; i<r; i++) a[i]=list.get(i-l);
  }

  private static void solve() {
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] xs = new int[n];
      for(int i = 0; i < n; i++)
      	xs[i] = sc.nextInt();
      for(int i = 0; i < n; i++)
      	sc.nextInt();

      sort(xs);

      int[] leftMaxCnt = new int[n];
      for(int i = 0; i < n; i++) {
      	if(i == 0) {
      		leftMaxCnt[i] = 1;
      		continue;
      	}

      	int target = xs[i] - k;
      	int left = 0, right = i;
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] < target) {
      			left = mid + 1;
      		} else {
      			right = mid - 1;
      		}
      	}

      	leftMaxCnt[i] = Math.max(i - left + 1, leftMaxCnt[i-1]);
      }

      int[] rightMaxCnt = new int[n];

      for(int i = n - 1; i >= 0; i--) {
      	if(i == n-1) {
      		rightMaxCnt[i] = 1;
      		continue;
      	}
      	int left = i, right = n - 1;
      	int target = xs[i] + k;
      	// 1 1 1 2 2 2 2 4 5 6
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] <= target) {
      			left = mid + 1;
      		} else
      			right = mid - 1;
      	}
      	rightMaxCnt[i] = Math.max(right - i + 1, rightMaxCnt[i+1]);
      }
      int max = leftMaxCnt[0];
      for(int i = 1; i < n; i++) {
      	max = Math.max(max, leftMaxCnt[i-1] + rightMaxCnt[i]);
      }
      out.println(max);
  }

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

  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }

      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}


import java.io.*;
import java.util.*;
public class E {

  public static void main(String[] args) {
      int t = sc.nextInt();
      while(t-- > 0)
        solve();
      out.close();
  }

  private static void solve() {
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] xs = new int[n];
      for(int i = 0; i < n; i++)
      	xs[i] = sc.nextInt();
      for(int i = 0; i < n; i++)
      	sc.nextInt();

      Arrays.sort(xs);

      int[] leftMaxCnt = new int[n];
      for(int i = 0; i < n; i++) {
      	if(i == 0) {
      		leftMaxCnt[i] = 1;
      		continue;
      	}

      	int target = xs[i] - k;
      	int left = 0, right = i;
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] < target) {
      			left = mid + 1;
      		} else {
      			right = mid - 1;
      		}
      	}

      	leftMaxCnt[i] = Math.max(i - left + 1, leftMaxCnt[i-1]);
      }

      int[] rightMaxCnt = new int[n];

      for(int i = n - 1; i >= 0; i--) {
      	if(i == n-1) {
      		rightMaxCnt[i] = 1;
      		continue;
      	}
      	int left = i, right = n - 1;
      	int target = xs[i] + k;
      	// 1 1 1 2 2 2 2 4 5 6
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] <= target) {
      			left = mid + 1;
      		} else
      			right = mid - 1;
      	}
      	rightMaxCnt[i] = Math.max(right - i + 1, rightMaxCnt[i+1]);
      }
      int max = leftMaxCnt[0];
      for(int i = 1; i < n; i++) {
      	max = Math.max(max, leftMaxCnt[i-1] + rightMaxCnt[i]);
      }
      out.println(max);
  }

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

  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }

      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}


import java.io.*;
import java.util.*;
public class E {

  public static void main(String[] args) {
      int t = sc.nextInt();
      while(t-- > 0)
        solve();
      out.close();
  }
public static void sort(int[] a ,int l, int r) {
    ArrayList<Integer> list=new ArrayList<>();
    for (int i=l ; i<r; i++) list.add(a[i]);
    Collections.sort(list);
    for (int i=l; i<r; i++) a[i]=list.get(i-l);
}
  private static void solve() {
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] xs = new int[n];
      for(int i = 0; i < n; i++)
      	xs[i] = sc.nextInt();
      for(int i = 0; i < n; i++)
      	sc.nextInt();

      sort(xs, 0, n - 1);

      int[] leftMaxCnt = new int[n];
      for(int i = 0; i < n; i++) {
      	if(i == 0) {
      		leftMaxCnt[i] = 1;
      		continue;
      	}

      	int target = xs[i] - k;
      	int left = 0, right = i;
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] < target) {
      			left = mid + 1;
      		} else {
      			right = mid - 1;
      		}
      	}

      	leftMaxCnt[i] = Math.max(i - left + 1, leftMaxCnt[i-1]);
      }

      int[] rightMaxCnt = new int[n];

      for(int i = n - 1; i >= 0; i--) {
      	if(i == n-1) {
      		rightMaxCnt[i] = 1;
      		continue;
      	}
      	int left = i, right = n - 1;
      	int target = xs[i] + k;
      	// 1 1 1 2 2 2 2 4 5 6
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] <= target) {
      			left = mid + 1;
      		} else
      			right = mid - 1;
      	}
      	rightMaxCnt[i] = Math.max(right - i + 1, rightMaxCnt[i+1]);
      }
      int max = leftMaxCnt[0];
      for(int i = 1; i < n; i++) {
      	max = Math.max(max, leftMaxCnt[i-1] + rightMaxCnt[i]);
      }
      out.println(max);
  }

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

  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }

      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}


import java.io.*;
import java.util.*;
public class E {

  public static void main(String[] args) {
      int t = sc.nextInt();
      while(t-- > 0)
        solve();
      out.close();
  }
public static void sort(int[] a ,int l, int r) {
    ArrayList<Integer> list=new ArrayList<>();
    for (int i=l ; i<r; i++) list.add(a[i]);
    Collections.sort(list);
    for (int i=l; i<r; i++) a[i]=list.get(i-l);
}
  private static void solve() {
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] xs = new int[n];
      for(int i = 0; i < n; i++)
      	xs[i] = sc.nextInt();
      for(int i = 0; i < n; i++)
      	sc.nextInt();

      sort(xs, 0, n);

      int[] leftMaxCnt = new int[n];
      for(int i = 0; i < n; i++) {
      	if(i == 0) {
      		leftMaxCnt[i] = 1;
      		continue;
      	}

      	int target = xs[i] - k;
      	int left = 0, right = i;
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] < target) {
      			left = mid + 1;
      		} else {
      			right = mid - 1;
      		}
      	}

      	leftMaxCnt[i] = Math.max(i - left + 1, leftMaxCnt[i-1]);
      }

      int[] rightMaxCnt = new int[n];

      for(int i = n - 1; i >= 0; i--) {
      	if(i == n-1) {
      		rightMaxCnt[i] = 1;
      		continue;
      	}
      	int left = i, right = n - 1;
      	int target = xs[i] + k;
      	// 1 1 1 2 2 2 2 4 5 6
      	while(left <= right) {
      		int mid = left + (right - left) / 2;
      		if(xs[mid] <= target) {
      			left = mid + 1;
      		} else
      			right = mid - 1;
      	}
      	rightMaxCnt[i] = Math.max(right - i + 1, rightMaxCnt[i+1]);
      }
      int max = leftMaxCnt[0];
      for(int i = 1; i < n; i++) {
      	max = Math.max(max, leftMaxCnt[i-1] + rightMaxCnt[i]);
      }
      out.println(max);
  }

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

  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }

      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}


import java.io.*;
import java.util.*;
public class E {

  public static void main(String[] args) {
      int t = sc.nextInt();
      while(t-- > 0)
        solve();
      out.close();
  }

  private static void solve() {
      int n = sc.nextInt();
      int k = sc.nextInt();
      int[] xs = new int[n];
      for(int i = 0; i < n; i++)
      	xs[i] = sc.nextInt();
      for(int i = 0; i < n; i++)
      	sc.nextInt();

      Arrays.sort(xs);

      int[] leftMaxCnt = new int[n];
      TreeMap<Integer, Integer> treeMap = new TreeMap<>();
      for(int i = 0; i < n; i++) {
      	int rightBound = xs[i];

      	if(!treeMap.containsKey(rightBound))
      		treeMap.put(rightBound, i);

      	int leftBound = rightBound - k;
      	Integer lowerBoundKey = treeMap.ceilingKey(leftBound);
      	leftMaxCnt[i] = i - treeMap.get(lowerBoundKey) + 1;
      	if(i > 0)
      		leftMaxCnt[i] = Math.max(leftMaxCnt[i], leftMaxCnt[i-1]);
      }

      int[] rightMaxCnt = new int[n];
      treeMap = new TreeMap<>();
      for(int i = n - 1; i >= 0; i--) {
      	int leftBound = xs[i];

      	if(!treeMap.containsKey(leftBound))
      		treeMap.put(leftBound, i);

      	int rightBound = leftBound + k;
      	Integer floorKey = treeMap.floorKey(rightBound);

      	rightMaxCnt[i] = treeMap.get(floorKey) - i + 1;
      	if(i < n - 1)
      		rightMaxCnt[i] = Math.max(rightMaxCnt[i], rightMaxCnt[i+1]);
      }
      int max = leftMaxCnt[0];
      for(int i = 1; i < n; i++) {
      	max = Math.max(max, leftMaxCnt[i-1] + rightMaxCnt[i]);
      }
      out.println(max);
  }

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

  public static FastScanner sc = new FastScanner();

  static class FastScanner {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st=new StringTokenizer("");
      String next() {
        while (!st.hasMoreTokens())
          try {
            st=new StringTokenizer(br.readLine());
          } catch (IOException e) {
            e.printStackTrace();
          }
        return st.nextToken();
      }

      int nextInt() {
        return Integer.parseInt(next());
      }
      int[] readArray(int n) {
        int[] a=new int[n];
        for (int i=0; i<n; i++) a[i]=nextInt();
        return a;
      }
      long nextLong() {
        return Long.parseLong(next());
      }
  }
}


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

 public class Task{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}

//sort map w.r.t value use-> TreeSet of array? write comparator which depends on all the entries of array otherwise weired behavior you can prove it.
//......................................@uthor_Alx..............................................
  static void sort(int[] p){
    List<Integer> l=new ArrayList<>();
    for(int i=0;i<p.length;i++){l.add(p[i]);}
    Collections.sort(l);
    for(int i=0;i<p.length;i++){
        p[i]=l.get(i);
    }
  }
   static int bs(int[] p, int max){
        int l=0,r=p.length-1,ans=0;
        while(l<=r){
            int m=(l+r)/2;
            if(p[m]<=max){
                ans=m;
                l=m+1;
            }
            else{
                r=m-1;
            }
        }
        return ans;
   }
   public static void main(String[] args) throws  IOException{
                assign();
                int t=int_v(read()),cn=1;
                while(t--!=0){
                    int[] x1=int_arr();
                    int n=x1[0],k=x1[1];//,y=x1[2];//,y=x1[3],n=x1[4];
                    int[] p=int_arr(),y=int_arr();
                    sort(p);
                    int rx=0,ry=0,max1=0;
                    int[] pre=new int[n];
                    for(int i=0;i<n;i++){
                        int max=p[i]+k;
                        int j=bs(p,max);
                         int c=j-i+1;
                        if(ry-rx+1<c){
                            rx=i;ry=j;
                        }
                        pre[i]=c;
                    }
                    for(int i=n-2;i>=0;i--){
                        pre[i]=Math.max(pre[i+1],pre[i]);
                    }
                    for(int i=0;i<n;i++){
                        int max=p[i]+k;
                        int j=bs(p,max);
                         int c=j-i+1;
                        if(ry-rx+1<c){
                            rx=i;ry=j;
                        }
                        if(j+1<n) max1=Math.max(max1,c+pre[j+1]);
                    }

                    out.write((Math.max(max1,pre[0]))+"\n");

                }
                    out.flush();

    }
}


"""
// Author : snape_here - Susanta Mukherjee

 """

from __future__ import division, print_function

import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

def read():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')

def isPrime(n):
    if (n <= 1) : return False
    if (n <= 3) : return True
    if (n % 2 == 0 or n % 3 == 0) : return False
    i = 5
    while(i * i <= n) :
        if (n % i == 0 or n % (i + 2) == 0) :
            return False
        i = i + 6
    return True

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

mod=1000000007

from math import log,sqrt,factorial,cos,tan,sin,radians,ceil,floor

import bisect

from decimal import *

getcontext().prec = 25

abc="abcdefghijklmnopqrstuvwxyz"

pi=3.141592653589793238

def fn(n):
    c=0
    while n%2==0:
        c+=1
        n//=2
    return c

def main():

    n=ii()
    a=li()
    p=[]
    s=0
    for i in range(n):
        s+=a[i]
        p.append(s)
    m=ii()
    q=li()
    for i in range(m):
        c=bisect.bisect_left(p,q[i])
        print(c+1)

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()

if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    #read()
    main()


N = int(raw_input())
entradas = map(int, raw_input().split())
juicys = int(raw_input())
m = map(int, raw_input().split())
total = sum(entradas)

mapa = {}
pilha = 1
n = 0
fim = entradas[n]
for i in range(total):
	numero = i + 1
	if (numero <= fim):
		mapa[numero] = pilha
	else:
		pilha += 1
		n += 1
		fim = fim + entradas[n]
		mapa[numero] = pilha

for i in range(juicys):
	print mapa[m[i]]


def buscaBinaria(lista, elemento):
	inicio = 0
	fim = len(lista) - 1

	while (inicio <= fim):
		meio = (inicio + fim) / 2
		if elemento == lista[meio]:
			return meio

		elif (elemento < lista[meio] and meio == 0):
			return meio
		elif (elemento < lista[meio] and elemento > lista[meio-1]):
			return meio

		elif (elemento < lista[meio]):
			fim = meio - 1
		else:
			inicio = meio + 1

	return -1

N = int(raw_input())
entradas = map(int, raw_input().split())
juicys = int(raw_input())
m = map(int, raw_input().split())

vetor = [0]*N
acumulada = 0
for i in range(N):
	acumulada += entradas[i]
	vetor[i] = acumulada

for i in range(juicys):
	print buscaBinaria(vetor, m[i]) + 1


def buscaBinaria(lista, elemento):
	inicio = 0
	fim = len(lista) - 1

	while (inicio <= fim):
		meio = (inicio + fim) / 2
		if (lista[meio] == elemento):
			return meio
		elif (elemento < lista[meio]):
			fim = meio - 1
		else:
			inicio = meio + 1

	return -1

N = int(raw_input())
entradas = map(int, raw_input().split())
juicys = int(raw_input())
m = map(int, raw_input().split())

for i in range(juicys):
	inicio = 1
	ultimo = entradas[0]
	for j in range(N):
		if buscaBinaria(range(inicio,ultimo+1),m[i]) != -1:
			print j + 1
			break

		inicio = ultimo + 1
		ultimo = ultimo + entradas[j+1]


def solve(cumsum, N, num):

	l = -1
	h = N

	# [l, h)
	while l + 1 < h:

		mid = (l+h)/2

		if cumsum[mid+1] < num:
			l = mid
		else:
			h = mid
	return h + 1

N = input()
arr = map(int, raw_input().split())
input()
nums = map(int, raw_input().split())
# arr = [ 2, 7, 3, 4, 9]
# nums = [1,25,11]
# N = 5
cumsum = [0]
for i in xrange(1, N + 1):
	cumsum.append(cumsum[i-1] + arr[i-1])
# print cumsum

for num in nums:
	print solve(cumsum, N, num)


"""
Online_Judges = Codeforces
Hacker = black_horse2016
Language = Python2.7.10
"""
import bisect
def GOD():
    N = int(input())
    a = map(int, raw_input().split())
    for i in xrange(1, N):
        a[i] += a[i-1]
    M = int(input())
    q = map(int, raw_input().split())
    for i in q:
        index = bisect.bisect_left(a, i) + 1
        print index
GOD()


def binarySearch(alvo, soma, pilhas):
	inicio = 0
	fim = pilhas - 1

	while True:

		if inicio > fim:

			break

		meio = (fim + inicio) / 2

		if soma[meio] < alvo:

			inicio = meio + 1

		elif soma[meio] > alvo:

			fim = meio - 1

		else:

			inicio = meio
			break

	return inicio

pilhas = int(raw_input())

entrada = raw_input().split()
somaA = [0] * pilhas

for i in range(pilhas):

	if i > 0:

		somaA[i] += int(entrada[i]) + somaA[i-1]

	else:

		somaA[i] += int(entrada[i])

buscas = int(raw_input())
alvos = raw_input().split()

for i in range(buscas):

	print binarySearch(int(alvos[i]), somaA, pilhas) + 1


n = raw_input()
numberOfWorms = map(int, raw_input().split())
m = input()
juicyWorms = map(int, raw_input().split())

totalWorms = []
totalWorms.append(numberOfWorms[0])

for i in range(1,len(numberOfWorms)):
	totalWorms.append(numberOfWorms[i] + totalWorms[i-1])

for i in juicyWorms:
	for index, value in enumerate(totalWorms):
		if i <= value:
			print index+1
			break


n = raw_input()
numberOfWorms = map(int, raw_input().split())
m = input()
juicyWorms = map(int, raw_input().split())

for i in range(1,len(numberOfWorms)):
	numberOfWorms[i] += numberOfWorms[i-1]

for i in juicyWorms:

	start = 0
	end = len(numberOfWorms) - 1

	while start <= end:
		mid = (end - start) / 2 + start

		if numberOfWorms[mid] < i:
			start = mid + 1
		else:
			end = mid - 1
	print start + 1


n = raw_input()
numberOfWorms = map(int, raw_input().split())
m = input()
juicyWorms = map(int, raw_input().split())

totalWorms = []
totalWorms.append(numberOfWorms[0])

for i in range(1,len(numberOfWorms)):
	totalWorms.append(numberOfWorms[i] + totalWorms[i-1])

# print(totalWorms)
# print(juicyWorms)

for i in juicyWorms:

	start = 0
	end = len(totalWorms) - 1

	while start <= end:
		mid = (end - start) / 2 + start

		# if totalWorms[mid] >= i:
			# print mid
			# break
		if totalWorms[mid] < i:
			start = mid + 1
		else:
			end = mid - 1
	print start + 1

	# for index, value in enumerate(totalWorms):
		# if i <= value:
			# print index+1
			# break


# coding =utf-8
n = int(input())
a = map(int,raw_input().split())
m = int(input())
q = map(int,raw_input().split())
t = []
for i in range(a[0]):
	t.append(1)
for i in range(1,n):
	a[i]+=a[i-1]
	for j in range(a[i-1],a[i]):
		t.append(i+1)
for i in q:
	print t[i-1]


def main():

    raw_input()
    A = [int(i) for i in raw_input().split(" ")]
    raw_input()
    B = [int(i) for i in raw_input().split(" ")]

    Bv2i = {}

    for i in range( len(B) ):
        if B[i] not in Bv2i:
            Bv2i[B[i]] = []
        Bv2i[B[i]].append(i)

    B.sort()

    R = [0]*len(B)

    pn = 1
    pm = A[pn-1]

    for i in B:
        while i > pm:
            pn += 1
            pm += A[pn-1]

        for index in Bv2i[i]:
            R[index] = pn

    for i in R:
        print i

main()


def main():

    raw_input()
    A = [int(i) for i in raw_input().split(" ")]
    raw_input()
    B = [int(i) for i in raw_input().split(" ")]

    Bi2v = {}
    Bv2i = {}

    for i in range( len(B) ):
        Bi2v[i] = B[i]
        if B[i] not in Bv2i:
            Bv2i[B[i]] = []
        Bv2i[B[i]].append(i)

    B.sort()

    R = [0]*len(B)

    pn = 1
    pm = A[pn-1]

    for i in B:
        while i > pm:
            pn += 1
            pm += A[pn-1]

        for index in Bv2i[i]:
            R[index] = pn

    for i in R:
        print i

main()


def main_tle():
    raw_input()
    A = [int(i) for i in raw_input().split(" ")]
    raw_input()
    B = [int(i) for i in raw_input().split(" ")]
    Bv2i = {}
    for i in range( len(B) ):
        if B[i] not in Bv2i:
            Bv2i[B[i]] = []
        Bv2i[B[i]].append(i)
    B.sort()
    R = [0]*len(B)
    pn = 1
    pm = A[pn-1]
    for i in B:
        while i > pm:
            pn += 1
            pm += A[pn-1]
        for index in Bv2i[i]:
            R[index] = pn
    for i in R:
        print i

def BS(A,mini,maxi,val):
    #print "in",mini,maxi,val

    if maxi - mini < 7:
        for i in range(mini,maxi+1):
            if A[i] >= val:
                return i+1

    mid = (mini+maxi)/2

    if A[mid] < val:
        return BS(A,mid,maxi,val)
    else:
        return BS(A,mini,mid,val)

def main_bs():
    raw_input()
    A = [int(i) for i in raw_input().split(" ")]
    raw_input()
    B = [int(i) for i in raw_input().split(" ")]

    intA = []
    for i in A:
        try:
            intA.append(intA[-1]+i)
        except:
            intA.append(i)

    #print intA
    for i in B:
        #print "val",i
        res = BS(intA,0,len(A)-1,i)
        print res

main_bs()


def main_tle():
    raw_input()
    A = [int(i) for i in raw_input().split(" ")]
    raw_input()
    B = [int(i) for i in raw_input().split(" ")]
    Bv2i = {}
    for i in range( len(B) ):
        if B[i] not in Bv2i:
            Bv2i[B[i]] = []
        Bv2i[B[i]].append(i)
    B.sort()
    R = [0]*len(B)
    pn = 1
    pm = A[pn-1]
    for i in B:
        while i > pm:
            pn += 1
            pm += A[pn-1]
        for index in Bv2i[i]:
            R[index] = pn
    for i in R:
        print i

def BS(A,mini,maxi,val):
    #print "in",mini,maxi,val
    if maxi - mini < 3:
        for i in range(mini,maxi+1):
            if A[i] >= val:
                return i+1
    mid = (mini+maxi)/2
    if A[mid] < val:
        return BS(A,mid,maxi,val)
    else:
        return BS(A,mini,mid,val)

def BS2(A,mini,maxi,val):
    while maxi-mini > 3:
        mid = (mini+maxi)/2
        if A[mid] < val:
            mini = mid
        else:
            maxi = mid
    for i in range(mini,maxi+1):
        if A[i] >= val:
            return i+1

def main_bs():
    raw_input()
    A = [int(i) for i in raw_input().split(" ")]
    raw_input()
    B = [int(i) for i in raw_input().split(" ")]

    intA = []
    for i in A:
        try:
            intA.append(intA[-1]+i)
        except:
            intA.append(i)

    #print intA
    for i in B:
        #print "val",i
        res = BS2(intA,0,len(A)-1,i)
        print res

main_bs()


n=input();rows=map(int,raw_input().split());q=input()
quer=sorted(enumerate(map(int,raw_input().split())),key=lambda x:x[1])
ans=[0]*q;sums=[rows[0]]+[0]*(n-1);ct=0
for i in xrange(1,n):
  sums[i]=sums[i-1]+rows[i]
for k,v in quer:
  while sums[ct]<v:
    ct+=1
  ans[k]=str(ct+1)
print "\n".join(ans)


n = int(raw_input(""))
piles = map(int, raw_input("").split())
m = int(raw_input(""))
labels = map(int, raw_input("").split())

calculatedPiles = []
currValue = 0
answerList = []

for i in piles:
    currValue += i
    calculatedPiles.append(currValue)

def findWorm(compareNum):
    low = 0
    high = n - 1
    answer = 0
    while (low <= high):
        mid = (low + high) // 2
        if compareNum > calculatedPiles[mid]:
            low = mid + 1
        elif compareNum <= calculatedPiles[mid]:
            high = mid - 1
            answer = mid + 1
    return answer

for i in labels:
    answerList.append(str(findWorm(i)))
print " ".join(answerList)


n = int(raw_input(""))
piles = map(int, raw_input("").split())
m = int(raw_input(""))
labels = map(int, raw_input("").split())

answerList = []

def calculate(pos):
    returnValue = 0
    for i in range(pos):
        returnValue += piles[i]
    return returnValue

def findWorm(compareNum):
    low = 0
    high = n - 1
    answer = 0
    while (low <= high):
        mid = (low + high) // 2
        if compareNum > calculate(mid + 1):
            low = mid + 1
        elif compareNum <= calculate(mid + 1):
            high = mid - 1
            answer = mid + 1
    return answer

for i in labels:
    answerList.append(str(findWorm(i)))
print " ".join(answerList)


n = int(raw_input(""))
piles = map(int, raw_input("").split())
m = int(raw_input(""))
labels = map(int, raw_input("").split())

answerList = []

def calculate(pos):
    returnValue = 0
    for i in range(pos):
        returnValue += piles[i]
    return returnValue

def findWorm(compareNum):
    low = 0
    high = n - 1
    answer = 0
    while (low <= high):
        mid = (low + high) // 2
        if compareNum > calculate(mid + 1):
            low = mid + 1
        else:
            high = mid - 1
            answer = mid + 1
    return answer

for i in labels:
    answerList.append(str(findWorm(i)))
print " ".join(answerList)


__author__ = 'walkerravina'
import sys
f = sys.stdin
n = int(f.readline().strip())
A = [int(i) for i in f.readline().split()]
A[0] = (1, A[0])
for i in range(1, len(A)):
    A[i] = (A[i - 1][1] + 1,  A[i] + A[i - 1][1])
q = int(f.readline().strip())
Q = [int(i) for i in f.readline().split()]

for d in Q:
    high = len(A) - 1
    low = 0
    done = False
    while not done:
        curr = (high - low) / 2 + low
        if d <= A[curr][1] and d >= A[curr][0]:
            print(curr + 1)
            done = True
        elif d > A[curr][1]:
            low = curr + 1
        else:
            high = curr - 1


__author__ = 'walkerravina'
import sys
f = sys.stdin
n = int(f.readline().strip())
A = [int(i) for i in f.readline().split()]
q = int(f.readline().strip())
Q = [int(i) for i in f.readline().split()]

for d in Q:
    k = A[0]
    i = 1
    while k < d:
        k += A[i]
        i += 1
    print(i)


from __future__ import division, print_function
# import threading
# threading.stack_size(2**27)
# import sys
# sys.setrecursionlimit(10**7)
from sys import stdin, stdout
import bisect            #c++ upperbound
import math
import heapq
i_m=9223372036854775807
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
import math
def GCD(x, y):
    x=abs(x)
    y=abs(y)
    if(min(x,y)==0):
        return max(x,y)
    while(y):
        x, y = y, x % y
    return x
def Divisors(n) :
    l = []
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) :
            if (n // i == i) :
                l.append(i)
            else :
                l.append(i)
                l.append(n//i)
    return l

def SieveOfEratosthenes(n):
    prime = [True for i in range(n+1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n):
        if prime[p]:
            f.append(p)
    return f
q=[]
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j

"""*******************************************************"""
def main():
    n=inin()
    a=ain()
    for i in range(1,n):
        a[i]=a[i-1]+a[i]
    m=inin()
    b=ain()
    for i in b:
        print(bisect.bisect_left(a,i)+1)

######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'R' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'R' [0]:
        A.append(sign*numb)
    return A

# threading.Thread(target=main).start()
if __name__== "__main__":
  main()


from __future__ import division, print_function

DEBUG = 0

import os, sys
from atexit import register
from io import BytesIO
import itertools

if sys.version_info[0] < 3:
    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

if DEBUG:
    debug_print = print
else:
    sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
    sys.stdout = BytesIO()
    register(lambda: os.write(1, sys.stdout.getvalue()))

    input = lambda: sys.stdin.readline().rstrip('\r\n')
    debug_print = lambda *x, **y: None

def input_as_list():
    return list(map(int, input().split()))

def array_of(f, *dim):
    return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()

def main():
    from bisect import bisect_left

    n = int(input())
    a = input_as_list()
    m = int(input())
    q = input_as_list()

    out = []
    asum = []
    for e in a:
        if not asum:
            asum.append(e)
        else:
            asum.append(asum[-1] + e)

    debug_print(asum)

    for e in q:
        out.append(bisect_left(asum, e)+1)

    print(*out, sep='\n')

main()


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

mod = int(1e9)+7

def binsearch(prefix, ele, n):
    l, r = 0, n
    while l <= r:
        mid = l+(r-l)//2
        if ele <= prefix[mid] and ele > prefix[mid-1]:
            return mid

        elif ele > prefix[mid]:
            l = mid+1

        else:
            r = mid-1

    return -1

n = iinput()
a = rlinput()
m = iinput()
j = rlinput()

prefix = [0]
for i in range(n):
    prefix.append(a[i]+prefix[i])
for i in j:
    print(binsearch(prefix,i,n+1))


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

mod = int(1e9)+7

n = iinput()
a = rlinput()
m = iinput()
j = rlinput()

sample=[]
pos=1
for i in a:
    sample+=[pos]*i
    pos+=1
for i in j:
    print(sample[i-1])


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
worm = []
for x in range(n):
    for y in range(a[x]):
        worm.append(x+1)
for x in range(m):
    print(worm[q[x]-1])


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
partsum = [0]*(n+1)
for x in range(n+1):
    partsum[x] = sum(a[0:x])
for x in range(m):
    for y in range(n):
        if partsum[y] < q[x] <= partsum[y + 1]:
            print(y+1)
            break


n = int(input())
a = [int(x) for x in input().split()]
m = int(input())
q = [int(x) for x in input().split()]
for i in range(m):
    worms = 0
    for j in range(n):
        if worms < q[i]:
            worms += a[j]
        if worms >= q[i]:
            print(j+1)
            break


def binarySearch(list, value, length):
    l = 0
    r = length-1
    while (l <= r):
        mid = (l + r) // 2
        #print(list[mid])
        if(list[mid-1] == list[length-1] and list[mid] >= value):
            return mid
        elif (list[mid-1] < value and list[mid] >= value):
            return mid
        elif (list[mid] > value):
            r = mid -1
        elif (list[mid] < value):
            l = mid + 1
    return "Not-found"

n = int(input())
aString = input()
aList = list(aString.split(' '))
aListInt = list(map(int, aList))

m = int(input())
qString = input()
qList = list(qString.split(" "))
qListInt = list(map(int, qList))

partialSum = 0
partialSumList = list()
for i in range(n):
    partialSum = partialSum + aListInt[i]
    partialSumList.append(partialSum)

for i in range(m):
    n = binarySearch(partialSumList, qListInt[i], len(partialSumList))
    print(n+1)

# for i in range(m):
#     for k in range(n):
#         if(partialSumList[k] >= qListInt[i]):
#             print(k+1)
#             break

# listMain = list()
#
# j = 1
#
# for i in range(n):
#     currentList = list()
#     while(j <= partialSumList[i]):
#         currentList.append(j)
#         j+=1
#     listMain.append(currentList)
#
#     for k in range(m):
#         if(binarySearch(currentList, qListInt[k], len(currentList)) != "Not-found"):
#             print(i+1)
#             #print("\n")
#


def binarySearch(list, value, length):
    l = 0
    r = length-1
    while (l <= r):
        mid = (l + r) // 2
        #print(list[mid])
        if (list[mid] == value):
            return mid
        elif (list[mid] > value):
            r = mid -1
        elif (list[mid] < value):
            l = mid + 1
    return "Not-found"

n = int(input())
aString = input()
aList = list(aString.split(' '))
aListInt = list(map(int, aList))

m = int(input())
qString = input()
qList = list(qString.split(" "))
qListInt = list(map(int, qList))

partialSum = 0
partialSumList = list()
for i in range(n):
    partialSum = partialSum + aListInt[i]
    partialSumList.append(partialSum)

# SOLUTION WITH TIME LIMIT ERROR
# for i in range(m):
#     for k in range(n):
#         if(partialSumList[k] >= qListInt[i]):
#             print(k+1)
#             break

# SOLUTION WITH INCORRECT OPUTPUT
listMain = list()

j = 1

for i in range(n):
    currentList = list()
    while(j <= partialSumList[i]):
        currentList.append(j)
        j+=1
    listMain.append(currentList)

    for k in range(m):
        if(binarySearch(currentList, qListInt[k], len(currentList)) != "Not-found"):
            print(i+1)
            #print("\n")


def binarySearch(list, value, length):
    l = 0
    r = length-1
    while (l <= r):
        mid = (l + r) // 2
        #print(list[mid])
        if (list[mid] == value):
            return mid
        elif (list[mid] > value):
            r = mid -1
        elif (list[mid] < value):
            l = mid + 1
    return "Not-found"

n = int(input())
aString = input()
aList = list(aString.split(' '))
aListInt = list(map(int, aList))

m = int(input())
qString = input()
qList = list(qString.split(" "))
qListInt = list(map(int, qList))

partialSum = 0
partialSumList = list()
for i in range(n):
    partialSum = partialSum + aListInt[i]
    partialSumList.append(partialSum)

# SOLUTION WITH TIME LIMIT ERROR
for i in range(m):
    for k in range(n):
        if(partialSumList[k] >= qListInt[i]):
            print(k+1)
            break

# SOLUTION WITH INCORRECT OPUTPUT
# listMain = list()
#
# j = 1
#
# for i in range(n):
#     currentList = list()
#     while(j <= partialSumList[i]):
#         currentList.append(j)
#         j+=1
#     listMain.append(currentList)
#
#     for k in range(m):
#         if(binarySearch(currentList, qListInt[k], len(currentList)) != "Not-found"):
#             print(i+1)
#             #print("\n")


def BS(A,x,l,h):
    if h>=l:
        m=(l+h)//2
        if A[m-1]<x<=A[m]:
            return m
        elif x<A[m]:
            return BS(A,x,l,m)
        elif x>A[m]:
            return BS(A,x,m,h)
    return 1

n=int(input())
A=list(map(int,input().split()))
m=int(input())
B=list(map(int,input().split()))
s=0
C=[]
for i in range(n):
    C.append(s)
    s=s+A[i]
C.append(s)
#print(C)
for i in B:
    print(BS(C,i,1,n+1))


# Anuneet Anand

def BS(A,x,l,h):
	if h-l>0:
		m = (l+h)//2
		if x<A[m]:
			return BS(A,x,l,m)
		else:
			return BS(A,x,m+1,h)
	else:
		if x>A[l]:
			return h
		else:
			return l

n = int(input())
A = list(map(int,input().split()))
m = int(input())
B = list(map(int,input().split()))

C = [1]
S = 0
for i in range(n):
	S = S + A[i]
	C.append(S+1)

C = list(set(C))

for i in range(m):
	print(BS(C,B[i],0,len(C)))


import numpy as np
input()
l = list(map(int, input().split()))
input()
li = list(map(int, input().split()))
l=np.cumsum(l)
for x in li:
    k=0
    for i in l:
        k+=1
        if (x<=i):
            print(k)
            break


n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=list(map(int,input().split()))
z=[]
for i in range(n):
    for j in range(a[i]):
        z.append(i+1)
for k in b:
    print(z[k-1])


def accumu(lis):
    total = 0
    for x in lis:
        total += x
        yield total
h=int(input())
l = list(map(int, input().split()))
k=int(input())
li = list(map(int, input().split()))
l=list(accumu(l))
for x in li:
    k=0
    for i in l:
        k+=1
        if (x<=i):
            print(k)
            break


# CODE BEGINS HERE.................
def search(l,i,p1,p2):
	mid =int((p1+p2)/2)
	# print(l[mid])
	if(l[mid]==i):
		return mid+1
	elif(i<l[mid]):
		if(mid==0):
			return 1
		if(l[mid-1]+1<=i):
			return mid+1
		else:
			return search(l,i,p1,mid)
	else:
		if(l[mid+1]>=i):
			return mid+2
		else:
			return search(l,i,mid+1,p2)

a=int(input())
k=list(map(int,input().split()))
l=[]
for i in range(a):
	# b=int(input())
	if(len(l)==0):
		l.append(k[i])
	else:
		l.append(k[i]+l[len(l)-1])
# print(l)
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
	print(search(l,m[i],0,len(l)-1))

#CODE ENDS HERE....................


# CODE BEGINS HERE.................
def search(l,i,p1,p2):
	mid =int((p1+p2)/2)
	# print(l[mid])
	if(l[mid]==i):
		return mid
	elif(i<l[mid]):
		if(mid==0):
			return 1
		if(l[mid-1]+1<=i):
			return mid+1
		else:
			return search(l,i,p1,mid)
	else:
		if(l[mid+1]>=i):
			return mid+2
		else:
			return search(l,i,mid+1,p2)

a=int(input())
k=list(map(int,input().split()))
l=[]
for i in range(a):
	# b=int(input())
	if(len(l)==0):
		l.append(k[i])
	else:
		l.append(k[i]+l[len(l)-1])
print(l)
n=int(input())
m=list(map(int,input().split()))
for i in range(n):
	print(search(l,m[i],0,len(l)-1))

#CODE ENDS HERE....................


# maa chudaaye duniya
def search(arr, lo, hi, x, n):
    while hi >= lo:
        mid = lo + (hi-lo)//2
        if arr[mid] == x:
            return mid
        elif x > arr[mid]:
            lo = mid + 1
        else:
            hi = mid - 1
    if hi < lo:
        if mid == 0 or mid == n-1:
            return mid
        else:
            if x >= arr[mid] and x <= arr[mid+1]:
                return mid + 1
            else:
                return mid

n = int(input())
arr = list(map(int, input().split()))
for i in range(1, n):
    arr[i] += arr[i-1]
m = input()
# print(*arr)
for i in list(map(int, input().split())):
    print(search(arr, 0, n-1, i, n) + 1)


# maa chudaaye duniya
def search(arr, lo, hi, x, n):
    while hi >= lo:
        mid = lo + (hi-lo)//2
        if arr[mid] == x:
            return mid
        elif x > arr[mid]:
            lo = mid + 1
        else:
            hi = mid - 1
    if hi < lo:
        if mid == 0 or mid == n-1:
            return mid
        else:
            if x >= arr[mid] and x <= arr[mid+1]:
                return mid + 1
            else:
                return mid - 1

n = int(input())
arr = list(map(int, input().split()))
for i in range(1, n):
    arr[i] += arr[i-1]
m = input()
# print(*arr)
for i in list(map(int, input().split())):
    print(search(arr, 0, n-1, i, n) + 1)


# maa chudaaye duniya
from bisect import bisect_left

n = int(input())
arr = list(map(int, input().split()))
for i in range(1, n):
    arr[i] += arr[i-1]
m = input()
for i in list(map(int, input().split())):
    print(bisect_left(arr, i) + 1)


# maa chudaaye duniya
def search(arr, lo, hi, x, n):
    while hi >= lo:
        mid = lo + (hi-lo)//2
        if arr[mid] == x:
            return mid
        elif x > arr[mid]:
            lo = mid + 1
        else:
            hi = mid - 1
    if hi < lo:
        if mid == 0 or mid == n-1:
            return mid
        else:
            if x >= arr[mid] and x <= arr[mid+1]:
                return mid + 1

n = int(input())
arr = list(map(int, input().split()))
for i in range(1, n):
    arr[i] += arr[i-1]
m = input()
# print(*arr)
for i in list(map(int, input().split())):
    print(search(arr, 0, n-1, i, n) + 1)


"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
def binarySearch (arr, l, r, x):

    # Check base case
    if r >= l:

        mid = l + (r - l)//2

        # If element is present at the middle itself
        if arr[mid][0] <=x and arr[mid][1] >= x:
            return mid

        # If element is smaller than mid, then it can only
        # be present in left subarray
        elif arr[mid][1] > x:
            return binarySearch(arr, l, mid-1, x)

        # Else the element can only be present in right subarray
        else:
            return binarySearch(arr, mid+1, r, x)

    else:
        # Element is not present in the array
        return -1
piles = int(input())
piles_arr = list(map(int, input().split()))
guesses = int(input())
guess_arr = list(map(int, input().split()))

sum_arr = [(0 , piles_arr[0])]
counter = piles_arr[0]
for i in range(1, piles):
    curr = counter
    counter += piles_arr[i]
    sum_arr.append((curr + 1, counter))
for element in guess_arr:
    print(binarySearch(sum_arr, 0, len(sum_arr), element) + 1)


"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
piles = int(input())
piles_arr = list(map(int, input().split()))
guesses = int(input())
guess_arr = list(map(int, input().split()))

sum_arr = [piles_arr[0]]
counter = piles_arr[0]
for i in range(1, piles):
    counter += piles_arr[i]
    sum_arr.append(counter)
for element in guess_arr:
    for j in range(len(sum_arr)):
        if sum_arr[j] >= element:
            print(j + 1)
            break


"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
def binarySearch (arr, l, r, x):

    # Check base case
    if r >= l:

        mid = l + (r - l)//2

        # If element is present at the middle itself
        if arr[mid][0] <=x and arr[mid][1] >= x:
            return mid

        # If element is smaller than mid, then it can only
        # be present in left subarray
        elif arr[mid][0] > x:
            return binarySearch(arr, l, mid-1, x)

        # Else the element can only be present in right subarray
        else:
            return binarySearch(arr, mid+1, r, x)

    else:
        # Element is not present in the array
        return -1
piles = int(input())
piles_arr = list(map(int, input().split()))
guesses = int(input())
guess_arr = list(map(int, input().split()))

sum_arr = [(0 , piles_arr[0])]
counter = piles_arr[0]
for i in range(1, piles):
    curr = counter
    counter += piles_arr[i]
    sum_arr.append((curr, counter))
for element in guess_arr:
    print(binarySearch(sum_arr, 0, len(sum_arr), element) + 1)


"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
def binarySearch (arr, l, r, x):

    # Check base case
    if r >= l:

        mid = l + (r - l)//2

        # If element is present at the middle itself
        if arr[mid][0] <=x and arr[mid][1] >= x:
            return mid

        # If element is smaller than mid, then it can only
        # be present in left subarray
        elif arr[mid][0] > x:
            return binarySearch(arr, l, mid-1, x)

        # Else the element can only be present in right subarray
        else:
            return binarySearch(arr, mid+1, r, x)

    else:
        # Element is not present in the array
        return -1
piles = int(input())
piles_arr = list(map(int, input().split()))
guesses = int(input())
guess_arr = list(map(int, input().split()))

sum_arr = [(0 , piles_arr[0])]
counter = piles_arr[0]
for i in range(1, piles):
    curr = counter
    counter += piles_arr[i]
    sum_arr.append((curr + 1, counter))
for element in guess_arr:
    print(binarySearch(sum_arr, 0, len(sum_arr), element) + 1)


"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
piles = int(input())
piles_arr = list(map(int, input().split()))
guesses = int(input())
guess_arr = list(map(int, input().split()))

sum_arr = [piles_arr[0]]
counter = piles_arr[0]
for i in range(1, piles):
    counter += piles_arr[i]
    sum_arr.append(counter)
for element in guess_arr:
    if element < sum_arr[0]:
        print(1)
        continue
    for j in range(len(sum_arr) - 1):
        if element >= sum_arr[j] and element <= sum_arr[j+1]:
            print(j+2)


"""
arr = list(map(int, input().split()))
n,k=map(int, input().split())
"""
def binarySearch (arr, l, r, x):

    # Check base case
    if r >= l:

        mid = l + (r - l)//2

        # If element is present at the middle itself
        if arr[mid][0] <=x and arr[mid][1] >= x:
            return mid

        # If element is smaller than mid, then it can only
        # be present in left subarray
        elif arr[mid][1] > x:
            return binarySearch(arr, l, mid-1, x)

        # Else the element can only be present in right subarray
        else:
            return binarySearch(arr, mid+1, r, x)

    else:
        # Element is not present in the array
        return -1
piles = int(input())
piles_arr = list(map(int, input().split()))
guesses = int(input())
guess_arr = list(map(int, input().split()))

sum_arr = [(0 , piles_arr[0])]
counter = piles_arr[0]
for i in range(1, piles):
    curr = counter
    counter += piles_arr[i]
    sum_arr.append((curr, counter))
for element in guess_arr:
    print(binarySearch(sum_arr, 0, len(sum_arr), element) + 1)


n = int(input())
arr = list(map(int,input().split()))
m = int(input())
juicy1 = list(map(int,input().split()))
juicy = sorted(juicy1)
pref = [0 for i in range(n)]
pref[0]=arr[0]
for i in range(1,n):
    pref[i]=arr[i]+pref[i-1]

arr1 = [None]+[i for i in range(1,sum(arr)+1)]
arr2 = []
for i in range(len(pref)):
    if i==0:
        arr2 += arr1[:pref[i]+1]+[None]
    else:
        arr2+= arr1[pref[i-1]+1:pref[i]+1]+[None]

dic = {}
t = 1
i = 1
j=0
while i<= sum(arr)+n:
    if arr2[i]==None:
        t+=1
        i+=1
    elif arr2[i]==juicy[j]:
        dic[juicy[j]]=t
        j+=1
        i+=1

    else:
        i+=1

for i in juicy1:
    print(dic[i])


n= int(input())
a=list(map(int,input().split()))
m=int(input())
q=list(map(int,input().split()))

pref = [0 for i in range(n)]
pref[0]=a[0]
for i in range(1,n):
    pref[i]=pref[i-1]+a[i]
pref=[0]+pref

for x in q:
    l=0
    r=n
    while l<=r:
        mid=(l+r)//2
        if x>pref[mid] and x<=pref[r]:
            l=mid
        elif x<=pref[mid] and x>=pref[l]:
            r=mid
        if r-l<=1:
            print(r)
            break


n = int(input())
list1 = list(map(int,input().split()))
m = int(input())
list2 = list(map(int,input().split()))
for i in range(m):
    count = 0
    for k in range(n):
        if list2[i] <= count:
            print(k)
            break
        else:
            count += list1[k]
    if k == n-1:
        print(n)


n = int(input())
list1 = list(map(int,input().split()))
m = int(input())
list2 = list(map(int,input().split()))
list3 = []
count = 0
for i in range(n):
    count += list1[i]
    list3.append(count)
for l in range(m):
    k = n//2
    while True:
        if list2[l] <= list3[k]:
            if k == 0:
                print(1)
                break
            elif list2[l] > list3[k-1]:
                print(k+1)
                break
            else:
                k = k - 1
        else:
            if k == n-1:
                print(n)
                break
            elif list2[l] <= list3[k+1]:
                print(k+2)
                break
            else:
                k = k + 1


n = int(input())
list1 = list(map(int,input().split()))
m = int(input())
list2 = list(map(int,input().split()))
for i in range(m):
    count = 0
    for k in range(n):
        count += list1[k]
        if list2[i] <= count:
            print(k+1)
            break


n = int(input())
list1 = list(map(int,input().split()))
m = int(input())
list2 = list(map(int,input().split()))
w = [0]*100002
s = 1
for i in range(n):
    w[s:s+list1[i]] = [i+1]*list1[i]
    s += list1[i]
for k in range(m):
    print(w[list2[k]])


'''
my bibary search didn't work
'''
# ossan

def bin_search(li, k, l, h):
    m = (l + h) // 2
    if k == li[m]:
        return m+1
    elif li[m-1] < k < li[m] and m != 0:
        return m+1
    elif k < li[m] and m == 0:
        return m+1
    elif k > li[m] and m == len(li)-1:
        return m+1
    elif k > li[m]:
        return bin_search(li, k, m + 1, h)
    else:
        return bin_search(li, k, l, m - 1)

n = int(input())
worm_piles = list(map(int, input().split()))
for i in range(1, n):
    worm_piles[i] += worm_piles[i - 1]
m = int(input())
for i in input().split():
    t = int(i)
    print(bin_search(worm_piles, t, 0, n-1))


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda: list(map(int, cin().split()))

def binSearch(x):
	low = 0
	high = n
	while low <= high:
		mid = (high+low)//2
		if x > a[mid]:
			low += 1
		elif x < a[mid]:
			high -= 1
		else:
			return mid
	return mid

n , = mp()
a = [0]
a += list(map(lambda i: int(i)+a[-1], cin().split())) #mp()
m, = mp()
q = mp()
print(a)
#l = [a[0]]
#for i in range(1, n):
#	l += [l[-1] + a[i]]
for i in range(m):
	ans = binSearch(q[i])
	cout(str(ans) + '\n')


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda: list(map(int, cin().split()))

def binSearch(x):
	low = 0
	high = n-1
	while low <= high:
		mid = (high+low)//2
		if x > l[mid]:
			low += 1
		elif x < l[mid]:
			high -= 1
		else:
			return mid+1
	return mid+1

n , = mp()
a = mp()
m, = mp()
q = mp()

l = [a[0]]
for i in range(1, n):
	l += [l[-1] + a[i]]
for i in range(m):
	ans = binSearch(q[i])
	cout(str(ans) + '\n')


n=int(input())
a=list(map(int,input().split()))
m=int(input())
q=map(int,input().split())
d=dict()
a0=1
for i in range(n):
    for k in range(a0,a0+a[i]):
        d[k]=i+1
    a0+=a[i]

for u in q:
    print(d[u])


n=int(input())
a=list(map(int,input().split()))
m=int(input())
q=map(int,input().split())
def out(qi,a):
    a0=1
    for i in range(n):
        if qi in range(a0,a0+a[i]):
            return i+1
        else:
            a0+=a[i]

for k in q:
    print(out(k,a))


def binary(arr, k, lo = 0):
    hi = len(arr)
    while(lo < hi):
        mid = (lo + hi)//2
        if arr[mid] > k:
            hi = mid
        else:
            lo = mid + 1
    return lo

## taking input
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
## making arra for binary search
array = [a[0]]
for i in range(1, n):
    array.append(a[i]+array[-1])
## answering queries
for q in b:
    this = binary(array, q)
    if this > n-1:
        print(n)
    else:
        if array[this] == q:
            print(this)
        else:
            print(this + 1)


def binary(arr, k, lo = 0):
    hi = len(arr)
    while(lo < hi):
        mid = (lo + hi)//2
        if arr[mid] < k:
            lo = mid + 1
        else:
            hi = mid
    return lo

## taking input
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
## making arra for binary search
array = [a[0]]
for i in range(1, n):
    array.append(a[i]+array[-1])
## answering queries
for q in b:
    this = binary(array, q)
    if this == n:
        print(this)
    else:
        print(this + 1)


def binary(arr, k, lo = 0):
    hi = len(arr)
    while(lo < hi):
        mid = (lo + hi)//2
        if arr[mid] < k:
            lo = mid + 1
        else:
            hi = mid
    return lo

## taking input
n = int(input())
a = list(map(int, input().split()))
m = int(input())
b = list(map(int, input().split()))
## making arra for binary search
array = [a[0]]
for i in range(1, n):
    array.append(a[i]+array[-1])
## answering queries
for q in b:
    this = binary(array, q-0.1)
    print(min(this+1, n))


import bisect
n = int(input())
a = [int(i) for i in input().split()]
pref = [0] * (n + 1)
for i in range(1, n + 1):
    pref[i] = pref[i - 1] + a[i - 1]
m = int(input())
b = [int(i) for i in input().split()]
for i in range(m):
    now = b[i]
    index = bisect.bisect_left(pref, now)
    print(index)


def bsearch(lis, num):
    n=len(lis)
    first=0
    last=n-1
    while(first<=last):
        mid=(first+last)//2
        if(lis[mid]<=num<=lis[mid+1]):
            return mid
        elif(lis[mid]>num):
            last=mid-1
        elif(lis[mid+1]<num):
            first=mid+1

n=int(input())
nums=list(map(int,input().split()))
sums=[]
sums.append(0)
for i in range(0,n):
    sums.append(nums[i]+sums[i])
m=int(input())
quests=list(map(int,input().split()))
for quest in quests:
    ind=bsearch(sums,quest)
    print(ind+1)


def bsearch(lis, num):
    n=len(lis)
    first=0
    last=n-1
    while(first<=last):
        mid=(first+last)//2
        if(lis[mid]<=num<=lis[mid+1]):
            return mid
        elif(lis[mid]>num):
            last=mid-1
        elif(lis[mid+1]<num):
            first=mid+1

n=int(input())
nums=list(map(int,input().split()))
sums=[]
sums.append(0)
for i in range(0,n):
    sums.append(nums[i]+sums[i])
m=int(input())
quests=list(map(int,input().split()))
for quest in quests:
    ind=bsearch(sums,quest)
    if(sums[ind-1]<=quest<=sums[ind]):
        print(ind)
    else:
        print(ind+1)


n=int(input())
lsn=list(map(int,input().split()))
m=int(input())
lsm=list(map(int,input().split()))
lst=[]
c=0
for i in lsn:
	c=c+i
	lst.append(c)
#print(lst)
for j in lsm:
	s=0
	e=len(lst)-1
	#print(j)
	while 1:
		if e-s==1:
			print(e+1)
			break
		mid=int((s+e)/2)
		#print('start:'+str(s))
		#print('mid:'+str(mid))
		#print('end:'+str(e))
		if j>=lst[s] and j<=lst[mid]:
			e=mid
			#print('yes')
		elif j>=lst[mid] and j<=lst[e]:
			s=mid
			#print('ok')
		else:
			print('1')
			break


n=int(input())
lsn=list(map(int,input().split()))
m=int(input())
lsm=list(map(int,input().split()))
lsmO=lsm[:]
lsm.sort()
d={}
a=0
for i in range(1,n+1):
	lst=[x for x in range(a+1,a+1+lsn[i-1])]
	a=lst[len(lst)-1]
	#d[i]=lst
	for j in lsm:
		if j in lst:
			d[j]=i
			lsm.remove(j)
		else:
			break
for i in lsmO:
	print(d[i])


n=int(input())
lsn=list(map(int,input().split()))
m=int(input())
lsm=list(map(int,input().split()))
lst=[]
c=0
for i in lsn:
	c=c+i
	lst.append(c)
#print(lst)
for j in lsm:
	s=0
	e=len(lst)-1
	#print(j)
	while 1:
		if e-s==1:
			print(e+1)
			break
		mid=int((s+e)/2)
		#print('start:'+str(s))
		#print('mid:'+str(mid))
		#print('end:'+str(e))
		if j>lst[s] and j<=lst[mid]:
			e=mid
			#print('yes')
		elif j>=lst[mid] and j<=lst[e]:
			s=mid
			#print('ok')
		else:
			print('1')
			break


n=int(input())
sep=list(map(int,input().split()))
nums=int(input())
ip=map(int,input().split())
s=sum(sep)
l,step=[0]*(s+1),
for i in sep:
    step+=i
    l[step]=1
for i in ip:
    print(sum(l[:i]))


n=int(input())
sep=list(map(int,input().split()))
nums=int(input())
ip=map(int,input().split())
s=sum(sep)
l,step=[0]*(s+1),0
for i in sep:
    step+=i
    l[step]=1
for i in ip:
    print(sum(l[:i])+1)


n=int(input())
sep=list(map(int,input().split()))
nums=int(input())
ip=map(int,input().split())
s=sum(sep)
l=[0]*s
step,count=0,1
for i in sep:
    for k in range(step,step+i):
        l[k]=count
    step+=i
    count+=1
for i in ip:
    print(l[i-1])


def low(brr,c,l,r):
	mid=int (l+int((r-l)/2))
	if brr[mid]>=c and brr[mid-1] < c:
		return int(mid+1)
	elif brr[mid]>c:
		return int(low(brr,c,l,mid))
	elif brr[mid]<c:
		return int(low(brr,c,mid+1,r))

n=int(input())
arr=list(map(int,input().split(" ")))
srr=list(0 for i in range(n))
srr[0]=arr[0]
for i in range(1,n):
	srr[i]=srr[i-1]+arr[i]
k=int(input())
brr=list(map(int,input().split(" ")))
for i in range(k):
	if brr[i]<=srr[0]:
		print(1)
	elif brr[i]>srr[n-2]:
		print(n)
	else:
		print(low(srr,brr[i],0,n-1))


def binarySearch(a,q, start, end):
	mid=int (start+int((end-start)/2))
	if a[mid]>=q and a[mid-1] < q:
		return int(mid+1)
	elif a[mid]>q:
		return int(binarySearch(a,q,start,mid))
	elif a[mid]<q:
		return int(binarySearch(a,q,mid+1,end))

def main():
	n = int(input())
	a = [0]*n
	ip = [int(i) for i in input().split()]

	for i in range(n):
		a[i] = a[i-1] + ip[i]
	m = int(input())
	q = [int(i) for i in input().split()]

	#binary search
	for i in range(m):
		if q[i] <= a[0]:
			print(1)
		elif q[i] > a[n-2]:
			print(n)
		else:
			print(binarySearch(a,q[i], 0, n-1))
main()


#------------------------------what is this I don't know....just makes my mess faster--------------------------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

#----------------------------------Real game starts here--------------------------------------
'''

___________________THIS IS AESTROIX CODE________________________
                       KARMANYA GUPTA

'''
#_______________________________________________________________#
import math
def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x-1)
def lower_bound(li, num):
	answer = -1 #in case the number is not present in the list return -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer
def upper_bound(li, num):
	answer = -1 #in case the number is not present in the list return -1
	start = 0
	end = len(li)-1

	while(start <= end):
		middle = (end+start)//2

		if li[middle] <= num:
			answer = middle
			start = middle + 1

		else:
			end = middle - 1
	return answer
#_______________________________________________________________#

for t in range(1):
	n = int(input())
	worms = list(map(int, input().split()))

	for i in range(1, n):
		worms[i] += worms[i-1]
	m = int(input())
	queries = list(map(int, input().split()))

	for i in queries:
		print(lower_bound(worms, i)+1)


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        ll t,a,b,c,n;
        ll tt;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            ll mx=max(a,max(b,c));

            ll bka=abs(mx-a);
            ll bkb=abs(mx-b);
            ll bkc=abs(mx-c);

            ll sh=abs(n-(bka+bkb+bkc));

            if(sh%3==0)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        ll t,a,b,c,n;
        ll tt;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            tt=(ll)1*(a+b+c+n);
            if(tt%3==0 ||(a==b && b==c))cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        ll t,a,b,c,n;
        ll tt;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            tt=(ll)1*(a+b+c+n);
            if(tt%3)cout<<"NO"<<endl;
            else cout<<"YES"<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        ll t,a,b,c,n;
        ll tt;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            tt=(ll)1*(a+b+c+n);
            if(tt%3==0 || (a==b && b==c))cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        int t,a,b,c,n;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            ll tt=(a+b+c+n);
            if(tt%3==0 ||(a==b && b==c))cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        int t,a,b,c,n;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            ll tt=(a+b+c+n);
            if(tt%3==0)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        ll t,a,b,c,n;
        ll tt;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            ll mx=max(a,max(b,c));

            ll bka=abs(mx-a);
            ll bkb=abs(mx-b);
            ll bkc=abs(mx-c);

            ll alb=(bka+bkb+bkc);

             //cout<<alb<<endl;
            if(alb>n){cout<<"NO"<<endl;
            continue;
            }

            ll sh=abs(n-(alb));

            if(sh%3==0)cout<<"YES"<<endl;

            else cout<<"NO"<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)
#define pii pair<int, int>
#define fs first
#define sc second

using namespace std;

const ll INF=(1ll<<62)-1;
const int M=1e5+5;

 int main()
    {
        ios;
        ll t,a,b,c,n;
        ll tt;
        cin>>t;
        while(t--)
        {
            cin>>a>>b>>c>>n;
            tt=(ll)1*(a+b+c+n);
            if(tt%3==0)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }

    }


#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,n,h ;
cin>>h ;
while (h--) {
int ar[3];
cin >> ar[0] >> ar[1] >> ar[2] >> n;
sort(ar , ar+3);
n-=ar[2]-ar[0];
n-=ar[2]-ar[1];
if (n>=0&&n%3==0)cout << "YES" << endl;
else cout << "NO" << endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ long long int a,b,c,n,h ;
cin>>h ;
for (int i=0;i<h;i++) {

cin>>a>>b>>c>>n ;
if (n%((a-b)+(a-c))==0)
{cout<<"yes" ;
}
else if ((n%((b-a)+(b-c))==0))
{cout<<"yes" ;
}

else if ((n%((c-a)+(c-b))==0)) {cout<<"yes" ;}
else {cout<<"no";}
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,n,h ;
cin>>h ;
for (i=0;i<h;i++) {

cin>>a>>b>>c>>n ;
if ((a+b+c+n)%3==0) cout<<"YES"<<endl ;
else cout<<"NO"<<endl ;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,n,h ;
cin>>h ;
for (int i=0;i<h;i++) {
int ar[3];
cin >> ar[0] >> ar[1] >> ar[2];
sort(ar , ar+3);
n-=ar[2]-ar[0];
n-ar[2]-ar[0];
if (n>=0&&n%3==0)cout << "YES" << endl;
else cout << "NO" << endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,n,h ;
cin>>h ;
for (int i=0;i<h;i++) {
int ar[3];
cin >> ar[0] >> ar[1] >> ar[2];
sort(ar , ar+3);
n-=ar[2]-ar[0];
n-=ar[2]-ar[1];
if (n>=0&&n%3==0)cout << "YES" << endl;
else cout << "NO" << endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,n,h ;
cin>>h ;
for (int i=0;i<h;i++) {

cin>>a>>b>>c>>n ;
if ((a+b+c+n)%3==0) cout<<"YES"<<endl ;
else cout<<"NO"<<endl ;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,n,h ;
cin>>h ;
for (int i=0;i<h;i++) {
int ar[3];
cin >> ar[0] >> ar[1] >> ar[2];
sort(ar , ar+3);
n-=ar[2]-ar[0];
n-ar[2]-ar[1];
if (n>=0&&n%3==0)cout << "YES" << endl;
else cout << "NO" << endl;
}
}


#include<bits/stdc++.h>
using namespace std;
int main()
{ int a,b,c,n,h ;
cin>>h ;
for (int i=0;i<h;i++) {
int ar[3];
cin >> ar[0] >> ar[1] >> ar[2];
sort(ar , ar+3);
n-=ar[2]-ar[0];
n-ar[2]-ar[1];
cout << n << endl;
if (n>=0&&n%3==0)cout << "YES" << endl;
else cout << "NO" << endl;
}
}


#include<bits/stdc++.h>
using namespace std;
 int main(){
 	int t;
 	cin>>t;
 	while(t--){
 		long long int a,b,c,n;
 		cin>>a>>b>>c>>n;
 		long long int  sum=0;
		sum= (a+b+c+n)/3;
 		if (((sum-a + sum-b + sum -c )== n) && sum -a>0 && sum -b>0 && sum -c>0)

 			cout<<"YES"<<endl;
 		else
 			cout<<"NO"<<endl;
	 }
 }


#include<bits/stdc++.h>
using namespace std;
 int main(){
 	int t;
 	cin>>t;
 	while(t--){
 		long long int a,b,c,n;
 		cin>>a>>b>>c>>n;
 		long long int  sum=0;
		sum= (a+b+c+n)/3;
 		if (((sum-a + sum-b + sum -c )== n) && (sum -a>=0) && (sum -b>=0) && (sum -c>=0))

 			cout<<"YES"<<endl;
 		else
 			cout<<"NO"<<endl;
	 }
 }


#include<bits/stdc++.h>
using namespace std;
 int main(){
 	int t;
 	cin>>t;
 	while(t--){
 		int a,b,c,n;
 		cin>>a>>b>>c>>n;
 		long long int  sum=(a+b+c+n)/3;
 		if ((sum-a + sum-b + sum -c )== n)
 			cout<<"YES"<<endl;
 		else
 			cout<<"NO"<<endl;
	 }
 }


#include<bits/stdc++.h>
using namespace std;
 int main(){
 	int t;
 	cin>>t;
 	while(t--){
 		long long int a,b,c,n;
 		cin>>a>>b>>c>>n;
 		long long int  sum=0;
		sum= (a+b+c+n)/3;
 		if (((sum-a + sum-b + sum -c )== n)&&sum>c && n>0)

 			cout<<"YES"<<endl;
 		else
 			cout<<"NO"<<endl;
	 }
 }


#include<bits/stdc++.h>
using namespace std;
 int main(){
 	int t;
 	cin>>t;
 	while(t--){
 		long long int a,b,c,n;
 		cin>>a>>b>>c>>n;
 		long long int  sum=(a+b+c+n)/3;
 		if ((sum-a + sum-b + sum -c )== n)
 			cout<<"YES"<<endl;
 		else
 			cout<<"NO"<<endl;
	 }
 }


#include<bits/stdc++.h>
using namespace std;
 int main(){
 	int t;
 	cin>>t;
 	while(t--){
 		int a,b,c,n;
 		cin>>a>>b>>c>>n;
 		int sum=(a+b+c+n)/3;
 		if ((sum-a + sum-b + sum -c )== n)
 			cout<<"YES"<<endl;
 		else
 			cout<<"NO"<<endl;
	 }
 }


#include<bits/stdc++.h>
using namespace std;
 int main(){
 	int q;
	cin >> q;
	for (int i = 0; i < q; ++i) {
		int a[3], n;
		cin >> a[0] >> a[1] >> a[2] >> n;
		sort(a, a + 3);
		n -= 2 * a[2] - a[1] - a[0];
		if (n < 0 || n % 3 != 0) {
			cout << "NO" << endl;
		} else {
			cout << "YES" << endl;
		}
	}
 }


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[4];
	int t,n;
	cin>>t;
	for(int i=1;i<=t;i++)
	{
		cin>>a[1]>>a[2]>>a[3]>>n;
		sort(a+1,a+4);
		n=n-(a[3]-a[2]);n=n-(a[3]-a[1]);
		if(n>-1 && n % 3==0)cout<<"YES\n";else cout<<"NO\n";
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	int MAX,a,b,c;
	long long int need,n;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>n;
		MAX=max(a,b);
		MAX=max(MAX,c);
		need=MAX*3-a-b-c;
		if(n>-1&&(n-need)%3) cout<<"NO"<<endl;
			else cout<<"YES"<<endl;
		}
	}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	long long int a,b,c,n;
	long long int MAX,need;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>n;
		MAX=max(a,b);
		MAX=max(MAX,c);
		need=MAX*3-a-b-c;
		if(n==0){
			if(a==b&&b==c) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else{
			if((n-need)%3) cout<<"NO"<<endl;
			else cout<<"YES"<<endl;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int N=200005;
int main(){
	int t;
	long long a,b,c,n;
	long long MAX,need;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>n;
		MAX=max(a,b);
		MAX=max(MAX,c);
		need=MAX*3-a-b-c;
		if((n-need)%3!=0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	int MAX,a,b,c;
	long long int need,n;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>n;
		MAX=max(a,b);
		MAX=max(MAX,c);
		need=MAX*3-a-b-c;
		if(n==0){
			if(a==b&&b==c) cout<<"YES"<<endl;
			else cout<<"NO"<<endl;
		}
		else{
			if((n-need)%3) cout<<"NO"<<endl;
			else cout<<"YES"<<endl;
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
int N=200005;
int main(){
	int t;
	long long a,b,c,n;
	long long MAX,need;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>n;
		MAX=max(a,b);
		MAX=max(MAX,c);
		need=MAX*3-a-b-c;
		if((n-need)%3) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int t;
	long long int a,b,c,n;
	long long int MAX,need;
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>n;
		MAX=max(a,b);
		MAX=max(MAX,c);
		need=MAX*3-a-b-c;
		if((n-need)%3!=0) cout<<"NO"<<endl;
		else cout<<"YES"<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,T;
int main () {
	scanf ("%d",&T);
	while (T--) {
		scanf ("%d %d %d %d",&a,&b,&c,&n);
		int k=max(a,max(b,c)),flag=0;
		if (k-a+k-b+k-c>n) {
			printf ("NO\n");
			continue;
		}
		int t=k;
		n=(n-k)%3+k;
		for (k;k<=t+n;k++) {
			if (k-a+k-b+k-c==n) {
				flag++;break;
			}
		}
		if (flag==1) printf ("YES\n");
		else printf ("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,T;
int main () {
	scanf ("%d",&T);
	while (T--) {
		scanf ("%d %d %d %d",&a,&b,&c,&n);
		int k=max(a,max(b,c)),flag=0;
		n-=k*3-a-b-c;
		if (n>0&&n%3==0)
		printf ("YES\n");
		else printf ("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,T;
int main () {
	scanf ("%d",&T);
	while (T--) {
		scanf ("%d %d %d %d",&a,&b,&c,&n);
		int k=max(a,max(b,c)),flag=0;
		if (k-a+k-b+k-c>n) {
			printf ("NO\n");
			continue;
		}
		int t=k;
		//n=(n-k)%3+k;
		for (k;k<=t+n;k++) {
			if (k-a+k-b+k-c==n) {
				flag++;break;
			}
		}
		if (flag==1) printf ("YES\n");
		else printf ("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,T;
int main () {
	scanf ("%d",&T);
	while (T--) {
		scanf ("%d %d %d %d",&a,&b,&c,&n);
		int k=max(a,max(b,c)),flag=0;
		n-=k*3-a-b-c;
		if (n>=0&&n%3==0)
		printf ("YES\n");
		else printf ("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,T;
int main () {
	scanf ("%d",&T);
	while (T--) {
		scanf ("%d %d %d %d",&a,&b,&c,&n);
		int k=max(a,max(b,c)),flag=0;
		if (k-a+k-b+k-c>n) {
			printf ("NO\n");
			continue;
		}
		//n=(n-k)%3+k;
		for (k;k<=k+n;k++) {
			if (k-a+k-b+k-c==n) {
				flag++;break;
			}
		}
		if (flag==1) printf ("YES\n");
		else printf ("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,T;
int main () {
	scanf ("%d",&T);
	while (T--) {
		scanf ("%d %d %d %d",&a,&b,&c,&n);
		int k=max(a,max(b,c)),flag=0;
		if (n-(k*3-a-b-c)&&(n-(k*3-a-b-c))%3==0)
		printf ("YES\n");
		else printf ("NO\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,T;
int main () {
	scanf ("%d",&T);
	while (T--) {
		scanf ("%d %d %d %d",&a,&b,&c,&n);
		int k=max(a,max(b,c)),flag=0;
		if (k-a+k-b+k-c>n) {
			printf ("NO\n");
			continue;
		}
		int t=k;
		for (k;k*3-a-b-c<=n;k++) {
			if (k-a+k-b+k-c==n) {
				flag++;break;
			}
		}
		if (flag==1) printf ("YES\n");
		else printf ("NO\n");
	}
	return 0;
}