ambiguous permutation

import java.io.*;
import java.util.Scanner;

class test1 {

public static void main(String[] args)throws IOException {

    int count=1;

    BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
    
    while(true)
    {
        
        if(Integer.parseInt(br.readLine()) ==0)
        {
            break;
        }
        String str = br.readLine();
        String a[] =  str.split(" ");
     
     for(int i=0;i<a.length;i++)   
     {
         
      
         
    if(Integer.parseInt(a[Integer.parseInt(a[i])-1])==i+1)
    {
        count=1;
    }
         else
    {
        count=0;
    }
         
     }
     
     if(count==1)
     {
         System.out.println("ambiguous");
     }
     else
     {
         System.out.println("not ambiguous");
     }
        
    }
    
}

}

its running fine in my netbeans but getting wrong ans here ???

if(Integer.parseInt(a[Integer.parseInt(a[i])-1])==i+1)
{
count=1;
}
else
{
count=0;
break;
}

forgot to break it … just saw it got an ac … sry guys :slight_smile:

//