#include <bits/stdc++.h>
using namespace std;

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { for (auto& _e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } pre__;


int main(void) {
		int N;
	cin >> N;
	vec<int> A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	vec<int> om(3);
	
	bool f = true;
	for (int i = 0; i < N; ++i) {
		if (A[i] % 3 != 0) f = false;
	}
	if (f) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 0; i < N; ++i) {
		int x = A[i] % 3;
		om[x]++;
	}

	vec<int> m = om;
	int ans0 = m[0];

	int ans1 = 0;
	if (m[1] != 0) {
		int sum = 1;
		++ans1;
		m[1]--;
		while (1) {
			if (sum == 2) {
				if (m[2] == 0) {
					if (m[1] > 0)++ans1;
					break;
				}
				else {
					++ans1;
					m[2]--;
					sum += 2;
					sum %= 3;
				}
			}
			else if (sum == 1) {
				if (m[1] == 0) {
					if (m[2] > 0)++ans1;
					break;
				}
				else {
					++ans1;
					m[1]--;
					sum += 1;
					sum %= 3;
				}
			}
		}
	}
	m = om;
	int ans2 = 0;
	if (m[2] != 0) {
		int sum = 2;
		++ans2;
		m[2]--;
		while (1) {
			if (sum == 2) {
				if (m[2] == 0) {
					if (m[1] > 0)++ans2;
					break;
				}
				else {
					++ans2;
					m[2]--;
					sum += 2;
					sum %= 3;
				}
			}
			else if (sum == 1) {
				if (m[1] == 0) {
					if (m[2] > 0)++ans2;
					break;
				}
				else {
					++ans2;
					m[1]--;
					sum += 1;
					sum %= 3;
				}
			}
		}
	}

	cout << ans0 + max(ans1, ans2) << endl;
	return 0;
}
