import java.util.*; public class Main { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); HashMap<Integer, ArrayList<Integer>> map = new HashMap<>(); for(int i = 0; i < n; i++){ int key = scanner.nextInt(); if(!map.containsKey(key)){ map.put(key, new ArrayList<>()); } map.get(key).add(i + 1); } int m = scanner.nextInt(); for(int i = 0; i < m; i++){ int l = scanner.nextInt(), r = scanner.nextInt(), k = scanner.nextInt(); int cnt = 0; ArrayList<Integer> arr = map.get(k); // System.out.println(arr.toString() + " " + k); int p = 0, q = arr.size() - 1; while (p < q) { int mid = (p + q) / 2; if(arr.get(mid) < l){ p = mid + 1; }else if(arr.get(mid) > l){ q = mid - 1; }else{ q = mid - 1; } } // System.out.println(p + " " + q); while (q < arr.size()) { if(q >= 0 && arr.get(q) >= l && arr.get(q) <= r){ cnt++; } if(q >= 0 && arr.get(q) > r){ break; } q++; } System.out.println(cnt); } } }