package asdf;
import java.util.ArrayList;
public class Q1 {
public static void main(String[] fuckingCopyRightBreaker){
IO io = new IO();
int n = io.nextInt();
ArrayList<Integer> apples = new ArrayList<Integer>();
int sum = 0, applesSum = 0;
for(int i = 0; i < n; i++){
int temp = io.nextInt();
if(temp % 3 != 0){
apples.add(temp);
applesSum += temp;
applesSum %= 3;
}else{
sum++;
}
}
if(applesSum == 0){
io.print((sum + apples.size()));
io.close();
return;
}
for(int i: apples){
if(i % 3 == applesSum){
io.print((sum + apples.size() - 1));
io.close();
return;
}
}
for(int i: apples){
for(int j: apples){
if((i + j) % 3 == applesSum){
io.print((sum + apples.size() - 2));
io.close();
return;
}
}
}
io.println();
io.close();
}
}