import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); long base = 0; ArrayList list = new ArrayList<>(); list.add(base); for (int i = 0; i < n; i++) { base += sc.nextInt(); list.add(base); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int type = sc.nextInt(); int left = sc.nextInt(); int right = sc.nextInt(); if (type == 1) { for (int j = left; j < right; j++) { list.remove(left); } } else { sb.append(list.get(right) - list.get(left - 1)).append("\n"); } } System.out.print(sb); } }