import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = Integer.valueOf(scan.nextLine().trim());
String[] strs = scan.nextLine().split(" ");
int[] nums = new int[n];
for (int i = 0; i < n; i++) {
nums[i] = Integer.valueOf(strs[i].trim());
}
int multiple3 = 0;
int multiple5 = 0;
System.out.println(process(multiple3, multiple5, nums, 0));
}
public static boolean process(int multiple3, int multiple5, int[] nums, int index) {
if (index == nums.length) {
if (multiple3 == multiple5) {
return true;
} else {
return false;
}
}
int currentNum = nums[index];
if (currentNum % 5 == 0) {
if (process(multiple3, multiple5 + currentNum, nums, index + 1)) {
return true;
} else {
return false;
}
} else if (currentNum % 3 == 0) {
if (process(multiple3 + currentNum, multiple5, nums, index + 1)) {
return true;
} else {
return false;
}
} else {
if (process(multiple3, multiple5 + currentNum, nums, index + 1)) {
return true;
}
if (process(multiple3 + currentNum, multiple5, nums, index + 1)) {
return true;
}
return false;
}
}
}