public static void main(String[] args)
	{
		boolean[] primes = new boolean[100000000];
		for (int i = 2; i < 100000000; i++)
			primes[i] = true;
		for (int i = 2; i < 100000000; i++)
			if (primes[i])
				for (int j = 2; i*j < 100000000; j++)
					primes[i*j] = false;
		ArrayList<Integer> primeList = new ArrayList<Integer>();
		for (int i = 0; i < 100000000; i++)
			if (primes[i])
				primeList.add(i);
		
		long startTime = System.currentTimeMillis();
		
		long sum = 0L;
		for (int i = 2; i < primeList.size(); i++)
		{
			ArrayList<Long> factorialMods = new ArrayList<Long>();
			factorialMods.add(1L);
			int currentPrime = primeList.get(i);
			System.out.println(i);
			long n = 1L;
			for (int j = 1; j < currentPrime; j++)
			{
				n *= j;
				n %= currentPrime;
				factorialMods.add(n);
			}
			long currentSum = 0L;
			for (int j = factorialMods.size()-5; j < factorialMods.size(); j++)
				currentSum += factorialMods.get(j);
			sum += currentSum%currentPrime;
		}
		
		System.out.println("Answer: " + sum);
		
		long endTime   = System.currentTimeMillis();
		long totalTime = endTime - startTime;
		System.out.println("time: " + totalTime);
		
	}