Untitled

 avatar
unknown
plain_text
4 years ago
549 B
3
Indexable
import java.util.Scanner;
import java.lang.Math;
public class Main {
    
	public static void main(String[] args)
	{
	     Scanner t = new Scanner(System.in);
	     int n =t.nextInt();
	     int[] a = new int[100];
	     int i;
	     int d1 = 0, d2= 0;
	     for(i = 0;i<n;i++)
	     {
	    	 a[i] = t.nextInt();
	     }
        for(i = 0; i < n;i++)
        {
            if(a[i] == 1)
	    	 {
	    		 d1+=1;
	    	 }
	    	 else d2+=1;
        }
	     int count = Math.abs(d2 - d1);
	     System.out.print(count);
	}
}
Editor is loading...