/* * Code Author: Akshay Miterani * DA-IICT */ import java.io.*; import java.math.*; import java.util.*; public class Main { InputReader in; PrintWriter out; Main() throws IOException { in = new InputReader(System.in); out = new PrintWriter(System.out); //in = new InputReader(new FileInputStream("output_.txt")); //out = new PrintWriter(new File("output_.txt")); solve(); out.close(); } public static void main(String args[]) { new Thread(null, new Runnable() { public void run() { try { new Main(); } catch (Exception e) { e.printStackTrace(); } } }, "1", 1 << 26).start(); } //--------------------My Code Starts Here---------------------- int mod=(int)1e9+7; long dp[][]=new long[1210][1210]; public void solve() throws IOException{ setup(); int n=in.nextInt(); int a[]=in.readIntBrray(n); long sum=0; for(int i=0;i 0){ if(b%2 == 1){ x=(x*y)%c; } y = (y*y)%c; // squaring the base b /= 2; } return x%c; } static class Pair implements Comparable{ int x; int y; int i; long size; int pos; Pair(int xx,int yy){ x=xx; y=yy; } @Override public int compareTo(Pair o) { if(Long.compare(this.x, o.x)!=0) return -Long.compare(this.x, o.x); else return Long.compare(this.y, o.y); } } public static void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } static final class InputReader{ private final InputStream stream; private final byte[] buf=new byte[1024]; private int curChar; private int numChars; public InputReader(InputStream stream){this.stream=stream;} private int read()throws IOException{ if(curChar>=numChars){ curChar=0; numChars=stream.read(buf); if(numChars<=0) return -1; } return buf[curChar++]; } public final int nextInt()throws IOException{return (int)nextLong();} public final long nextLong()throws IOException{ int c=read(); while(isSpaceChar(c)){ c=read(); if(c==-1) throw new IOException(); } boolean negative=false; if(c=='-'){ negative=true; c=read(); } long res=0; do{ if(c<'0'||c>'9')throw new InputMismatchException(); res*=10; res+=(c-'0'); c=read(); }while(!isSpaceChar(c)); return negative?(-res):(res); } public final int[] readIntBrray(int size)throws IOException{ int[] arr=new int[size]; for(int i=0;i