MATAPAN RUN TIME ERROR

import java.util.Scanner;

import java.util.Arrays;

    public class Main {

   public static void main(String args[]) {
    Scanner test = new Scanner(System.in);
    int tests = test.nextInt();
    for (int bo = 0; bo < tests; bo++) {
        Scanner sc = new Scanner(System.in);
        int[] integers = new int[26];
        int i, sum = 0;
        for (i = 0; i < 26; i++) {
            integers[i] = sc.nextInt();
        }
        int sum2 = 0;
        for (i = 0; i < 26; i++) {
            sum2 += integers[i];
        }
        Scanner string = new Scanner(System.in);
        String sr;
        sr = string.nextLine();

        char[] charArray = sr.toCharArray();
        Arrays.sort(charArray);
        String sortedString = new String(charArray);
        String srt = "abcdefghijklmnopqrstuvwxyz";
        char[] abc = srt.toCharArray();
        for (int k = 0; k < charArray.length; k++) {
            for (int j = 0; j < 26; j++) {
                if (abc[j] == charArray[k]) {
                    sum = sum + integers[j];


                } else {
                    int p = 0;
                }
            }
        }
        int op = sum2 - sum;
        System.out.print(op);


    }
}

}

i guess you do not the the frequency array concept , see in all these frequencies problems what you need to do is just simply create an array of 26 elements initialized 0.

the simply iterate through the string.

for(i=0;i<s.length();i++)
arr[s[i]-'a']=1:

what this will do is whichever elements are present , for e.g if a is present then 0th pos off arr will be filled with 1 , and then you can just iterate through the array of 26 elements to check which elements are 0 , indicting that they are not present , simply calculate the sum.
sum=0

for (int i=0;i<26;i++)
{
if (a[i]==0)
sum+=s[i]
}

print sum