import java.io.*;

public class enigmatic_gk implements Runnable {
    static Reader in;
    static PrintWriter out;

    static final int mod = 2010;
    static final int total = 12;
    static final int preperiod = 2; 

    int[][] trees;
    int[] s;
    int[] c;
    int p;
    int[][] inc;

    public void run() {
        int n = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        
        inc = new int[total][total];
        for (int i = 0; i < total; i++) {
            for (int j = 0; j < total; j++) {
                inc[i][j] = inc(i, j);
            }
        }

        for (p = 1; p < n; p *= 2);

        trees = new int[2 * p][total];
        s = new int[2 * p];
        c = new int[2 * p];
        for (int j = 0; j < n; j++) {
            int z = a[j];
            for (int i = 0; i < total; i++) {
                trees[j + p][i] = z;
                z = (z * z) % mod;
            }
        }
        for (int i = 0; i < total; i++) {
            for (int j = p - 1; j > 0; j--) {
                trees[j][i] = trees[j * 2][i] + trees[j * 2 + 1][i];
            }
        }

        int m = nextInt();
        for (int i = 0; i < m; i++) {
            int type = nextInt();
            int l = nextInt();
            int r = nextInt();
            if (type == 1) {
                square(l - 1, r - 1, 0, p - 1, 1);
            } else {
                out.println(sum(l - 1, r - 1, 0, p - 1, 1));
            }
        }
    }

    private int nextInt() {
        try {
            int ch = in.read();
            while (ch < '0') {
                ch = in.read();
            }
            int result = 0;
            while (ch >= '0') {
                result = result * 10 + ch - '0';
                ch = in.read();
            }
            return result;
        } catch (IOException e) {
            throw new AssertionError(e);
        }
    }

    private void square(int l, int r, int sl, int sr, int v) {
        if (sr < l || r < sl) {
            return;
        }
        if (l <= sl && sr <= r) {
            push(v, 1);
        } else {
            unload(v);
            int sm = (sl + sr) / 2;
            square(l, r, sl, sm, v * 2);
            square(l, r, sm + 1, sr, v * 2 + 1);
            consolidate(v);
        }
    }

    private void unload(int v) {
        if (s[v] != 0) {
            push(v * 2, s[v]);
            push(v * 2 + 1, s[v]);
            s[v] = 0;
        }
    }   

    private void push(int v, int size) {
        s[v] = inc(s[v], size);
        c[v] = inc(c[v], size);
    }

    private void consolidate(int v) {
        int[] vt = trees[v];
        int[] lt = trees[v * 2];
        int[] rt = trees[v * 2 + 1];
        int[] al = inc[c[v * 2]];
        int[] ar = inc[c[v * 2 + 1]];
        for (int i = 0; i < total; i++) {
            vt[i] = lt[al[i]] + rt[ar[i]];
        }
        c[v] = 0;
    }    

    private int inc(int a, int b) {
        int r = a + b;
        while (r >= total) {
            r = r  - total + preperiod;
        }
        return r;
    }

    private int sum(int l, int r, int sl, int sr, int v) {
        if (sr < l || r < sl) {
            return 0;
        }
        if (l <= sl && sr <= r) {
            return trees[v][c[v]]; 
        } else  {
            unload(v);
            int sm = (sl + sr) / 2;
            return sum(l, r, sl, sm, v * 2) + sum(l, r, sm + 1, sr, v * 2 + 1);
        }
    }

    public static void main(String[] args) throws Exception {        
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);

        new enigmatic_gk().run();

        in.close();
        out.close();
    }
}
