Help me in solving FLAGS problem

My issue

give me the solution of this problem

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        
        while (t-- > 0) {
            int N = sc.nextInt();
            long ans = 0;
            
            // Corrected calculations with correct operations and data type
            ans += (2L * N * (N - 1) * (N - 1));
            ans += (N * (N - 1) * (N - 2));
            ans += (2L * N * (N - 1) * (N - 2) * (N - 2));
            
            System.out.println(ans);
        }
    }

}

Problem Link: Counting Flags Practice Coding Problem