Help me in solving SESO03 problem

My issue

what the issue in my code

My code

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

class Codechef
{
    public static void main(String[] args) throws java.lang.Exception
    {
        try{
            int[] arr={3 ,5 ,1 ,4 ,5 ,6 ,5 ,6};
            boolean flag=false;
            for(int i=0;i<8;i++){
                if(arr[i]==1){
                    flag=true;
                    System.out.print("Yes");
                }
                else
                System.out.print("no");
            }
        }
        catch(ArrayIndexOutOfBoundsException e){
            System.out.print(e);
            
        }

        

        

    }
}

Learning course: Design and analysis of Algorithms
Problem Link: https://www.codechef.com/learn/course/abesit-daa/ABESITDA15/problems/SESO03


what you did is you put the print statement in for loop which result in printing "yes"or “no” when the condition is true or false