#include<bits/stdc++.h>
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define s second
#define f first
using namespace std;

int main(void){
  int n,ary[3] = {0},in,ret = 0;
  cin>>n;
  rep(i,n){
    cin>>in;
    ary[in%3] ++;
  }
  if(ary[1] || ary[2]) ret = ary[0];
  int mi = min(ary[1],ary[2]);
  int diff = max(ary[1],ary[2]) - mi;
  //cout<<diff<<endl;
  ret = ret + mi * 2 + min(3,diff);
  //cout<< min(3,diff)<<endl;

  
  
  cout<<(ret==0&&ary[0]?1:ret)<<endl;
}