Power Pokemon A Power Pokemon Couple is a pair of pokemons with a sum of their power levels equal to

import java.util.*;

public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] power = new int[n];

    for (int i = 0; i < n; i++) {
        power[i] = scanner.nextInt();
    }
    
    
    int mod = 1000000007;
    int[] powerCount = new int[23];
    
    for (int p : power) {
        if (p >= 0 && p < 23) {
            powerCount[p]++;
        }
    }
    
    long ans = 0;
    
    for (int i = 0; i < 23; i++) {
        for (int j = i; j < 23; j++) {
            if ((i + j == 0 || (i + j & (i + j - 1)) == 0) && (i == j || powerCount[i] > 0 && powerCount[j] > 0)) {
                if (i == j) {
                    ans = (ans + (powerCount[i] * (powerCount[i] - 1L) / 2L) % mod) % mod;
                } else {
                    ans = (ans + (powerCount[i] * 1L * powerCount[j]) % mod) % mod;
                }
            }
        }
    }
    
    System.out.println(ans);
}

}

Custom Test Case

EXECUTE

Result

Your Output

2

Expected Output

5

only this test case is failing and rest is running perfectly