Help me in solving ZCO14003 problem

My issue

Exception in thread “main” java.util.NoSuchElementException
at java.base/java.util.Scanner.throwFor(
at java.base/
at java.base/java.util.Scanner.nextInt(
at java.base/java.util.Scanner.nextInt(
at Main.main(
why is this eating my brain… and i also tried to copy paste submitted solution from all submissions still i am getting the same error

My code

import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(;
        int N= sc.nextInt();
        long[] budgets = new long[N];

        for (int i = 0; i < N; i++) {
            budgets[i] = sc.nextLong();

        long maxRevenue = findMaxRevenue(budgets);

    public static long findMaxRevenue(long[] budgets) {
        int n = budgets.length;
        long maxRevenue = 0;

        for (int i = 0; i < n; i++) {
            long revenue = budgets[i] * (n - i);
            if (revenue > maxRevenue) {
                maxRevenue = revenue;

        return maxRevenue;

Problem Link: CodeChef: Practical coding for everyone