Rupsa and the Game: What's wrong with this code?

import java.math.BigInteger;
import java.util.Scanner;
class Wandbox
----public static void main(String[] args)
--------Scanner sc = new Scanner(;
--------BigInteger T = sc.nextBigInteger();
--------BigInteger dos = new BigInteger(“2”);
--------BigInteger modulo = new BigInteger(“1000000007”);
--------for (BigInteger bi = T; bi.compareTo(BigInteger.ZERO) > 0; bi = bi.subtract(BigInteger.ONE)) {
------------BigInteger N = sc.nextBigInteger(); BigInteger ant = new BigInteger(“0”); BigInteger suma = new BigInteger(“0”);
------------for (BigInteger bii = N; bii.compareTo(BigInteger.ZERO) > -1; bii = bii.subtract(BigInteger.ONE)){
----------------BigInteger E = sc.nextBigInteger();
----------------BigInteger multi = E.multiply(ant);
----------------BigInteger sum = E.add(ant);
----------------ant = multi.add(sum);
----------------suma = suma.add(E);
------------ant = ant.subtract(suma);
------------ant = ant.multiply(dos);
------------ant = ant.mod(modulo);

You dont have to use big integer if you use modulo properly. Give a read to fast exponentiation, or perhaps try storing (power of 2)%mod in array and use it there after.

That, assuming you have got approach correct, its hard to tell your approach without comments.

Yeah, my approach was incorrect that was the problem.