import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int n=in.nextInt();
int[] a=new int[n];
for (int i=0;i<a.length;i++){
a[i]=in.nextInt();
}
List<Boolean> b=new ArrayList<>();
b=prefixesDivBy5(a);
for (boolean c:
b) {
System.out.print(c+" ");
}
}
public static List<Boolean> prefixesDivBy5(int[] A) {
List<Boolean> list = new ArrayList<Boolean>();
int prefix = 0;
int length = A.length;
for (int i = 0; i < length; i++) {
prefix = ((prefix << 1) + A[i]) % 5;
list.add(prefix == 0);
}
return list;
}
}