/*--------------------------------------------------------------*/
/* ACM ICPC 2009-2010, NEERC                                    */
/* Northern Subregional Contest                                 */
/* St Petersburg, October 17, 2009                              */
/*--------------------------------------------------------------*/
/* Problem E. Enigmatic Device                                  */
/*                                                              */
/* Original idea         Roman Satukov                          */
/* Problem statement     Andrew Lopatin                         */
/* Testset               Andrew Lopatin                         */
/*--------------------------------------------------------------*/
/* Solution                                                     */
/*                                                              */
/* Author                Andrew Lopatin                         */
/*--------------------------------------------------------------*/
 
import java.util.*;
import java.io.*;

public class enigmatic_al_arraycopy {
  static final int MaxN = 50000, MaxM = 50000, MOD = 2010;
  static final int P1 = 2, P2 = 10, TSize = 1 << 16;
  
  static int rangeInt (String s, int a, int b) {
    int x = Integer.parseInt (s);
    if (x < a || x > b) throw new RuntimeException (x + " is not in " + a + ".." + b);
    return x;
  }

  static int sqrmod (int x) {
    return (x * x) % MOD;
  }

  static int [][] T;
  static int [] F, L;
  static int l, r;


  static void localIncrement (int k, int v) {
    if (v >= P1 + P2) v = (v - P1) % P2 + P1;
    for (int i = 0; i < P1 + P2 - v; i++) {
      L[i] = T[k][i + v];
    }
    for (int i = 0; i < Math.min (v, P2); i++)
      L[P1 + P2 - v + i] = T[k][P1 + i];
    if (v >= P2)
      for (int i = 0; i < v - P2; i++)
        L[P1 + P2 - v + P2 + i] = T[k][P1 + i];

    int [] tmp = T[k];
    T[k] = L;
    L = tmp;
    F[k] += v;
  }

  static void push (int k) {
    if (F[k] > 0) {
      localIncrement (2 * k, F[k]);
      localIncrement (2 * k + 1, F[k]);
      F[k] = 0;
    }
  }


  static void increment (int k, int a, int b) {
    if (r < a || l > b) return;

    if (l <= a && b <= r) {
      localIncrement (k, 1);
      return;
    }

    push (k);
    int m = (a + b) >> 1;
    
    increment (2 * k, a, m);
    increment (2 * k + 1, m + 1, b);
      
    for (int i = 0; i < P1 + P2; i++)
      T[k][i] = T[2 * k][i] + T[2 * k + 1][i];
  }


  static int getSum (int k, int a, int b) {
    if (r < a || l > b) return 0;

    if (l <= a && b <= r) {
      return T[k][0];
    }

    push (k);
    int m = (a + b) >> 1;
    return getSum (2 * k, a, m) + getSum (2 * k + 1, m + 1, b);
  }

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

    int n = rangeInt (in.readLine (), 1, MaxN);
    StringTokenizer tok = new StringTokenizer (in.readLine ());
    int [] a = new int [n];

    for (int i = 0; i < n; i++)
      a[i] = rangeInt (tok.nextToken (), 0, MOD - 1);
    
    if (tok.hasMoreTokens ()) throw new Exception ("EOL required");

    T = new int [TSize * 2][P1 + P2];
    F = new int [TSize * 2];
    L = new int [P1 + P2];
    for (int i = 0; i < n; i++)
      T[TSize + i][0] = a[i];

    for (int j = 0; j < n; j++)
      for (int i = 1; i < P1 + P2; i++)
        T[TSize + j][i] = sqrmod (T[TSize + j][i - 1]);

    for (int j = TSize - 1; j > 0; j--)
      for (int i = P1 + P2 - 1; i >= 0; i--)
        T[j][i] = T[2 * j][i] + T[2 * j + 1][i];

    int m = rangeInt (in.readLine (), 1, MaxM);

    for (int i = 0; i < m; i++) {
      tok = new StringTokenizer (in.readLine ());
      int k = rangeInt (tok.nextToken (), 1, 2);
      l = rangeInt (tok.nextToken (), 1, MaxN) - 1;
      r = rangeInt (tok.nextToken (), l, MaxN) - 1;
      if (k == 1) {
        increment (1, 0, TSize - 1); 
      } else {
        out.println (getSum (1, 0, TSize - 1));
      }
      if (tok.hasMoreTokens ()) throw new Exception ("EOL required");
    }

    if (in.ready ()) throw new RuntimeException ("EOF expected");

    out.close ();
  }
}