/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2016.  Dmytro Karataiev
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

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

public class MajorityElement {
    private static int getMajorityElement(int[] a, int left, int right) {
        if (left == right) {
            return -1;
        }
        if (left + 1 == right) {
            return a[left];
        }
        //write your code here
        return -1;
    }

    public static void main(String[] args) {
        FastScanner scanner = new FastScanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        if (getMajorityElement(a, 0, a.length) != -1) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream stream) {
            try {
                br = new BufferedReader(new InputStreamReader(stream));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


@@ -1149,46 +1149,242 @@
 */%0A%0A
-import java.util.*;%0Aimport java.io.*;%0A
+package DivideConquer.majority_element;%0A%0Aimport java.util.*;%0Aimport java.io.*;%0A%0A/**%0A * Algorithm to calculate majority element in an array.%0A * It works in O(n Log n) and returns either a majority element or -1 if it's not present.%0A */
 %0Apub
@@ -1411,16 +1411,17 @@
 ement %7B%0A
+%0A
     priv
@@ -1478,32 +1478,33 @@
 t, int right) %7B%0A
+%0A
         if (left
@@ -1504,16 +1504,74 @@
 f (left 
+%3E right) %7B%0A            return -1;%0A        %7D else if (left 
 == right
@@ -1585,34 +1585,39 @@
          return 
--1
+a%5Bleft%5D
 ;%0A        %7D%0A    
@@ -1615,78 +1615,446 @@
    %7D
-%0A        if (left + 1 == right) %7B%0A            return a%5Bleft%5D;%0A
+ else %7B%0A%0A            int median = (left + right) / 2;%0A%0A            int one = getMajorityElement(a, left, median);%0A            int two = getMajorityElement(a, median + 1, right);%0A            if (one == two) %7B%0A                return one;%0A            %7D%0A%0A            int half = (right - left + 1) / 2;%0A%0A            if (one %3E -1) %7B%0A                if (getFrequency(a, left, right, one) %3E half) %7B%0A                    return one;%0A       
         
 %7D%0A  
@@ -2041,32 +2041,33 @@
 %0A               
+ 
 %7D%0A        //writ
@@ -2064,30 +2064,454 @@
     
-//write your code here
+    %7D%0A            if (two %3E -1) %7B%0A                if (getFrequency(a, left, right, two) %3E half) %7B%0A                    return two;%0A                %7D%0A            %7D%0A            return -1;%0A        %7D%0A%0A    %7D%0A%0A    private static int getFrequency(int%5B%5D a, int left, int right, int element) %7B%0A        int frequency = 0;%0A%0A        for (int i = left; i %3C= right; i++) %7B%0A            if (a%5Bi%5D == element) %7B%0A                frequency++;%0A            %7D%0A        %7D%0A
 %0A   
@@ -2518,26 +2518,33 @@
      return 
--1
+frequency
 ;%0A    %7D%0A%0A   
@@ -2786,32 +2786,104 @@
 nt();%0A        %7D%0A
+%0A        //System.out.println(getMajorityElement(a, 0, a.length - 1));%0A%0A
         if (getM
@@ -2911,16 +2911,20 @@
 a.length
+ - 1
 ) != -1)

Majority Elements algorithm