#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

int main(){
    int n;
    cin >> n;
    int cnt[3] = {};
    REP(i,n) {
        int tmp;
        cin >> tmp;
        cnt[tmp%3]++;
    }
    if (cnt[0] == n) {
        cout << 1 << endl;
        return 0;
    }
    int ans;
    if(cnt[1] < cnt[2] - 3){
        ans = cnt[1] * 2 + 3;
    }else if(cnt[1] <= cnt[2] + 3){
        ans = cnt[1] + cnt[2];
    }else{
        ans = cnt[2] * 2 + 3;
    }
    ans += cnt[0];
    cout << ans << endl;
    return 0;
}

