python 使用count會很快
l=[int(input())%3 for _ in range(int(input()))]
print(" ".join([str(l.count(i)) for i in range(3)]))