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

import static java.lang.Math.*;

public class Main {
    FastScanner in;
    PrintWriter out;

    static final String FILE = "powerstower";

    void solve() {
        int n = in.nextInt();
        int[] ms = new int[n];
        for (int i = 0; i < n; i++)
            ms[i] = in.nextInt();
        if (n == 1) {
            out.print(ms[0] % 3);
            return;
        }
        for (int i = n - 1; i >= 1; i--) {
            ms[i] %= 2;
            if (ms[i] == 0)
                ms[i] = 0;
            else
                ms[i] = 1;
            if (i + 1 < n && ms[i + 1] == 0)
                ms[i] = 1;
        }
        int old = ms[0];
        ms[0] %= 3;
        if (ms[0] != 2)
            out.print(ms[0]);
        else
            out.print(ms[1] == 0 ? 1 : 2);
    }

    public void run() {
        if (FILE.equals("")) {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
        } else {
            try {
                in = new FastScanner(new FileInputStream(FILE +
                        ".in"));
                out = new PrintWriter(new FileOutputStream(FILE +
                        ".out"));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }
        solve();
        out.close();
    }

    public static void main(String[] args) {
        (new Main()).run();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }
    }

}