#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

typedef long long R;
typedef complex<R> C;
#define x real()
#define y imag()

int n;

const int N = 1e5;

int par[N + 1], sgn[N + 1];

C vec[N + 1];

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
 	cin >> n;
	R t1, t2; cin >> t1 >> t2;
	C v0 = C(t1, t2), v1; sgn[0] = 1;
	int i0 = 0, i1 = -1;
	rep(i, 1, n){
		cin >> t1 >> t2;
		C v(t1, t2);
		if(norm(v0 + v) < max(norm(v0), norm(v))){
			v0 += v;
			par[i] = i0;
			sgn[i] = 1;
		} else if(norm(v0 - v) < max(norm(v0), norm(v))){
			v0 -= v;
			par[i] = i0;
			sgn[i] = -1;
		} else if(i1 == -1){
			v1 = v;
			par[i] = i;
			sgn[i] = 1;
		} else if(norm(v1 + v) < max(norm(v1), norm(v))){
			v1 += v;
			par[i] = i1;
			sgn[i] = 1;
		} else {
			v1 -= v;
			par[i] = i1;
			sgn[i] = -1;
		}
		if(i1 != -1){
			if(norm(v0 + v1) < max(norm(v0), norm(v1))){
				v0 += v1;
				par[i1] = i0;
				sgn[i1] = 1;
			} else if(norm(v0 - v1) < max(norm(v0), norm(v1))){
				v0 -= v1;
				par[i1] = i0;
				sgn[i1] = -1;
			}
		}
		DBG(v0, norm(v0), v1, norm(v1));
	}
	if(i1 != -1){
		par[i1] = i0;
		if(norm(v0 - v1) < norm(v0 + v1)){
			sgn[i1] = -1;
		} else {
			sgn[i1] = 1;
		}
	}
	DBG(norm(v0 + v1));
	rep(i, 0, n){
		if(par[i] != i){
			sgn[i] *= sgn[par[i]];
		}
		cout << sgn[i] << " ";
	}
	cout << "\n";
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

typedef long long R;
typedef complex<R> C;
#define x real()
#define y imag()

int n;

const int N = 1e5;

int par[N + 1], sgn[N + 1];

C vec[N + 1];

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
 	cin >> n;
	R t1, t2; cin >> t1 >> t2;
	C v0 = C(t1, t2), v1; sgn[0] = 1;
	int i0 = 0, i1 = -1;
	rep(i, 1, n){
		cin >> t1 >> t2;
		C v(t1, t2);
		if(norm(v0 + v) < max(norm(v0), norm(v))){
			v0 += v;
			par[i] = i0;
			sgn[i] = 1;
		} else if(norm(v0 - v) < max(norm(v0), norm(v))){
			v0 -= v;
			par[i] = i0;
			sgn[i] = -1;
		} else if(i1 == -1){
			v1 = v;
			par[i] = i;
			sgn[i] = 1;
		} else if(norm(v1 + v) < max(norm(v1), norm(v))){
			v1 += v;
			par[i] = i1;
			sgn[i] = 1;
		} else {
			v1 -= v;
			par[i] = i1;
			sgn[i] = -1;
		}
		if(i1 != -1){
			if(norm(v0 + v1) < max(norm(v0), norm(v1))){
				v0 += v1;
				par[i1] = i0;
				sgn[i1] = 1;
			} else if(norm(v0 - v1) < max(norm(v0), norm(v1))){
				v0 -= v1;
				par[i1] = i0;
				sgn[i1] = -1;
			}
		}
		DBG(v0, norm(v0), v1, norm(v1));
	}
	DBG(norm(v0 + v1));
	rep(i, 0, n){
		if(par[i] != i){
			sgn[i] *= sgn[par[i]];
		}
		cout << sgn[i] << " ";
	}
	cout << "\n";
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

typedef long long R;
typedef complex<R> C;
#define x real()
#define y imag()

int n;

const int N = 1e5;

int par[N + 1], sgn[N + 1];

C vec[N + 1];

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
 	cin >> n;
	R t1, t2; cin >> t1 >> t2;
	C v0 = C(t1, t2), v1; sgn[0] = 1;
	int i0 = 0, i1 = -1;
	rep(i, 1, n){
		cin >> t1 >> t2;
		C v(t1, t2);
		if(norm(v0 + v) < max(norm(v0), norm(v))){
			v0 += v;
			par[i] = i0;
			sgn[i] = 1;
		} else if(norm(v0 - v) < max(norm(v0), norm(v))){
			v0 -= v;
			par[i] = i0;
			sgn[i] = -1;
		} else if(i1 == -1){
			v1 = v;
			par[i] = i;
			sgn[i] = 1;
		} else if(norm(v1 + v) < max(norm(v1), norm(v))){
			v1 += v;
			par[i] = i1;
			sgn[i] = 1;
		} else {
			v1 -= v;
			par[i] = i1;
			sgn[i] = -1;
		}
		if(i1 != -1){
			if(norm(v0 + v1) < max(norm(v0), norm(v1))){
				v0 += v1;
				par[i1] = i0;
				sgn[i1] = 1;
			} else if(norm(v0 - v1) < max(norm(v0), norm(v1))){
				v0 -= v1;
				par[i1] = i0;
				sgn[i1] = -1;
			}
		}
		DBG(v0, norm(v0), v1, norm(v1));
	}
	assert(norm(v0) < 1000000000000ll and norm(v1) < 1000000000000ll);
	if(i1 != -1){
		par[i1] = i0;
		if(norm(v0 - v1) < norm(v0 + v1)){
			sgn[i1] = -1;
		} else {
			sgn[i1] = 1;
		}
	}
	DBG(norm(v0 + v1));
	rep(i, 0, n){
		if(par[i] != i){
			sgn[i] *= sgn[par[i]];
		}
		cout << sgn[i] << " ";
	}
	cout << "\n";
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 1e18L + 1;
const int IINF = 1e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

typedef long long R;
typedef complex<R> C;
#define x real()
#define y imag()

int n;

const int N = 1e5;

int par[N + 1], sgn[N + 1];

C vec[N + 1], acc[N + 1];

void mrg(int i, int j){
	par[j] = i;
	if(norm(acc[i] + acc[j]) <= norm(acc[i] - acc[j])){
		acc[i] += acc[j];
		sgn[j] = 1;
	} else {
		acc[i] -= acc[j];
		sgn[j] = -1;
	}
}

bool should_mrg(int i, int j){
	return min(norm(acc[i] + acc[j]), norm(acc[i] - acc[j])) <= max(norm(acc[i]), norm(acc[j]));
}

int main()
{
#ifndef LOCAL
	ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
 	cin >> n;
	R t1, t2; cin >> t1 >> t2;
	int i0 = 0, i1 = -1;
	par[0] = 0; sgn[0] = 1;vec[0] = C(t1, t2); acc[0] = vec[0];
	rep(i, 1, n){
		cin >> t1 >> t2;
		vec[i] = C(t1, t2); acc[i] = vec[i]; sgn[i] = 1; par[i] = i;
		if(should_mrg(i0, i)){
			mrg(i0, i);
		} else if(i1 == -1){
			i1 = i;
		} else {
			assert(should_mrg(i1, i));
			mrg(i1, i);
		}
		if(i1 != -1 and should_mrg(i0, i1)){
			mrg(i0, i1); i1 = -1;
		}
	}
	if(i1 != -1){
		mrg(i0, i1);
	}
	C res(0, 0);
	rep(i, 0, n){
		//DBG(i, par[i], sgn[i], vec[i], acc[i]);
		if(par[i] != i){
			sgn[i] *= sgn[par[i]];
		}
		res += R(sgn[i]) * vec[i];
		cout << sgn[i] << " ";
	}
	DBG(res);
	assert(res == acc[i0]);
	cout << "\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Node
{
    int id, tag;
    vector<Node*> child;
    Node(int);
};
Node::Node(int id)
{
    this->id = id;
    this->tag = 1;
}
const int MAXN = 1e5 + 10, V = 1e6;
int n, x[MAXN], y[MAXN], ans[MAXN];
Node* nod[MAXN];
long long sqr(int x)
{
    return (long long) x * x;
}
Node* merge(Node* a, Node* b)
{
    Node* c = new Node(0);
    c->child.push_back(a);
    c->child.push_back(b);
    return c;
}
void dfs(Node* a, int b)
{
    b *= a->tag;
    if(a->id)
        ans[a->id] = b;
    for(vector<Node*>::iterator i = a->child.begin(); i < a->child.end(); i++)
    {
        dfs(*i, b);
    }
}
int main()
{
    scanf("%d", &n);
    if(n == 1)
    {
        printf("1\n");
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d", &x[i], &y[i]);
        nod[i] = new Node(i);
    }
    for(int m = n; m > 2; m--)
    {
        if(sqr(x[m - 1] + x[m]) + sqr(y[m - 1] + y[m]) <= sqr(V))
        {
            x[m - 1] += x[m], y[m - 1] += y[m];
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 1] - x[m]) + sqr(y[m - 1] - y[m]) <= sqr(V))
        {
            x[m - 1] -= x[m], y[m - 1] -= y[m], nod[m]->tag = -1;
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m]) + sqr(y[m - 2] + y[m]) <= sqr(V))
        {
            x[m - 2] += x[m], y[m - 2] += y[m];
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] - x[m]) + sqr(y[m - 2] - y[m]) <= sqr(V))
        {
            x[m - 2] -= x[m], y[m - 2] -= y[m], nod[m]->tag = -1;
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m - 1]) + sqr(y[m - 2] + y[m - 1]) <= sqr(V))
        {
            x[m - 2] += x[m - 1], y[m - 2] += y[m - 1];
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
        else
        {
            x[m - 2] -= x[m - 1], y[m - 2] -= y[m - 1];
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
    }
    if(sqr(x[1] + x[2]) + sqr(y[1] + y[2]) < sqr(x[1] - x[2]) + sqr(y[1] - y[2]))
    {
        x[1] += x[2], y[1] += y[2];
        nod[1] = merge(nod[1], nod[2]);
    }
    else
    {
        x[1] -= x[2], y[1] -= y[2];
        nod[1] = merge(nod[1], nod[2]);
    }
    dfs(nod[1], 1);
    for(int i = 1; i <= n; i++)
        printf("%d ", ans[i]);
    printf("\n");
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n, x, y, cx, cy;
long long dis(int x, int y)
{
    return (long long) x * x + (long long) y * y;
}
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d", &x, &y);
        if(dis(cx + x, cy + y) < dis(cx - x, cy - y))
            cx += x, cy += y, printf("1 ");
        else
            cx -= x, cy -= y, printf("-1 ");
    }
    printf("\n");
}


#include <bits/stdc++.h>
using namespace std;
struct Node
{
    int id, tag;
    vector<Node*> child;
    Node(int);
};
Node::Node(int id)
{
    this->id = id;
    this->tag = 1;
}
const int MAXN = 1e5 + 10, V = 1e6;
int n, x[MAXN], y[MAXN], ans[MAXN];
Node* nod[MAXN];
long long sqr(int x)
{
    return (long long) x * x;
}
Node* merge(Node* a, Node* b)
{
    Node* c = new Node(0);
    c->child.push_back(a);
    c->child.push_back(b);
    return c;
}
void dfs(Node* a, int b)
{
    b *= a->tag;
    if(a->id)
        ans[a->id] = b;
    for(vector<Node*>::iterator i = a->child.begin(); i < a->child.end(); i++)
    {
        dfs(*i, b);
    }
}
int main()
{
    scanf("%d", &n);
    if(n == 1)
    {
        printf("1\n");
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d", &x[i], &y[i]);
        nod[i] = new Node(i);
    }
    for(int m = n; m > 2; m--)
    {
        if(sqr(x[m - 1] + x[m]) + sqr(y[m - 1] + y[m]) <= sqr(V))
        {
            x[m - 1] += x[m], y[m - 1] += y[m];
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 1] - x[m]) + sqr(y[m - 1] - y[m]) <= sqr(V))
        {
            x[m - 1] -= x[m], y[m - 1] -= y[m], nod[m]->tag = -1;
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m]) + sqr(y[m - 2] + y[m]) <= sqr(V))
        {
            x[m - 2] += x[m], y[m - 2] += y[m];
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] - x[m]) + sqr(y[m - 2] - y[m]) <= sqr(V))
        {
            x[m - 2] -= x[m], y[m - 2] -= y[m], nod[m]->tag = -1;
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m - 1]) + sqr(y[m - 2] + y[m - 1]) <= sqr(V))
        {
            x[m - 2] += x[m - 1], y[m - 2] += y[m - 1];
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
        else
        {
            x[m - 2] -= x[m - 1], y[m - 2] -= y[m - 1], nod[m - 1]->tag = -1;
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
    }
    if(sqr(x[1] + x[2]) + sqr(y[1] + y[2]) < sqr(x[1] - x[2]) + sqr(y[1] - y[2]))
    {
        x[1] += x[2], y[1] += y[2];
        nod[1] = merge(nod[1], nod[2]);
    }
    else
    {
        x[1] -= x[2], y[1] -= y[2], nod[2]->tag = -1;
        nod[1] = merge(nod[1], nod[2]);
    }
    dfs(nod[1], 1);
    for(int i = 1; i <= n; i++)
        printf("%d ", ans[i]);
    printf("\n");
}


#include <bits/stdc++.h>
using namespace std;
struct Node
{
    int id, tag;
    vector<Node*> child;
    Node(int);
};
Node::Node(int id)
{
    this->id = id;
    this->tag = 1;
}
const int MAXN = 1e5 + 10, V = 1e6;
int n, x[MAXN], y[MAXN], ans[MAXN];
Node* nod[MAXN];
long long sqr(int x)
{
    return (long long) x * x;
}
Node* merge(Node* a, Node* b)
{
    Node* c = new Node(0);
    c->child.push_back(a);
    c->child.push_back(b);
    return c;
}
void dfs(Node* a, int b)
{
    b *= a->tag;
    if(a->id)
        ans[a->id] = b;
    for(vector<Node*>::iterator i = a->child.begin(); i < a->child.end(); i++)
    {
        dfs(*i, b);
    }
}
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d", &x[i], &y[i]);
        nod[i] = new Node(i);
    }
    for(int m = n; m > 2; m--)
    {
        if(sqr(x[m - 1] + x[m]) + sqr(y[m - 1] + y[m]) <= sqr(V))
        {
            x[m - 1] += x[m], y[m - 1] += y[m];
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 1] - x[m]) + sqr(y[m - 1] - y[m]) <= sqr(V))
        {
            x[m - 1] -= x[m], y[m - 1] -= y[m], nod[m]->tag = -1;
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m]) + sqr(y[m - 2] + y[m]) <= sqr(V))
        {
            x[m - 2] += x[m], y[m - 2] += y[m];
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] - x[m]) + sqr(y[m - 2] - y[m]) <= sqr(V))
        {
            x[m - 2] -= x[m], y[m - 2] -= y[m], nod[m]->tag = -1;
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m - 1]) + sqr(y[m - 2] + y[m - 1]) <= sqr(V))
        {
            x[m - 2] += x[m - 1], y[m - 2] += y[m - 1];
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
        else
        {
            x[m - 2] -= x[m - 1], y[m - 2] -= y[m - 1];
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
    }
    if(sqr(x[1] + x[2]) + sqr(y[1] + y[2]) < sqr(x[1] - x[2]) + sqr(y[1] - y[2]))
    {
        x[1] += x[2], y[1] += y[2];
        nod[1] = merge(nod[1], nod[2]);
    }
    else
    {
        x[1] -= x[2], y[1] -= y[2];
        nod[1] = merge(nod[1], nod[2]);
    }
    dfs(nod[1], 1);
    for(int i = 1; i <= n; i++)
        printf("%d ", ans[i]);
    printf("\n");
}


#include <bits/stdc++.h>
using namespace std;
struct Node
{
    int id, tag;
    vector<Node*> child;
    Node(int);
};
Node::Node(int id)
{
    this->id = id;
    this->tag = 1;
}
const int MAXN = 1e5 + 10, V = 1e6;
int n, x[MAXN], y[MAXN], ans[MAXN];
Node* nod[MAXN];
long long sqr(int x)
{
    return (long long) x * x;
}
Node* merge(Node* a, Node* b)
{
    Node* c = new Node(0);
    c->child.push_back(a);
    c->child.push_back(b);
    return c;
}
void dfs(Node* a, int b)
{
    b *= a->tag;
    if(a->id)
        ans[a->id] = b;
    for(vector<Node*>::iterator i = a->child.begin(); i < a->child.end(); i++)
    {
        dfs(*i, b);
    }
}
int main()
{
    scanf("%d", &n);
    if(n == 1)
    {
        printf("1\n");
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d", &x[i], &y[i]);
        nod[i] = new Node(i);
    }
    for(int m = n; m > 2; m--)
    {
        if(sqr(x[m - 1] + x[m]) + sqr(y[m - 1] + y[m]) <= sqr(V))
        {
            x[m - 1] += x[m], y[m - 1] += y[m];
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 1] - x[m]) + sqr(y[m - 1] - y[m]) <= sqr(V))
        {
            x[m - 1] -= x[m], y[m - 1] -= y[m], nod[m]->tag = -1;
            nod[m - 1] = merge(nod[m - 1], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m]) + sqr(y[m - 2] + y[m]) <= sqr(V))
        {
            x[m - 2] += x[m], y[m - 2] += y[m];
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] - x[m]) + sqr(y[m - 2] - y[m]) <= sqr(V))
        {
            x[m - 2] -= x[m], y[m - 2] -= y[m], nod[m]->tag = -1;
            nod[m - 2] = merge(nod[m - 2], nod[m]);
        }
        else if(sqr(x[m - 2] + x[m - 1]) + sqr(y[m - 2] + y[m - 1]) <= sqr(V))
        {
            x[m - 2] += x[m - 1], y[m - 2] += y[m - 1];
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
        else
        {
            x[m - 2] -= x[m - 1], y[m - 2] -= y[m - 1];
            nod[m - 2] = merge(nod[m - 2], nod[m - 1]);
            x[m - 1] = x[m], y[m - 1] = y[m], nod[m - 1] = nod[m];
        }
        if(sqr(x[m]) + sqr(y[m]) > sqr(V))
        {
            printf("Error:%d\n", m);
        }
    }
    if(sqr(x[1] + x[2]) + sqr(y[1] + y[2]) < sqr(x[1] - x[2]) + sqr(y[1] - y[2]))
    {
        x[1] += x[2], y[1] += y[2];
        nod[1] = merge(nod[1], nod[2]);
    }
    else
    {
        x[1] -= x[2], y[1] -= y[2];
        nod[1] = merge(nod[1], nod[2]);
    }
    dfs(nod[1], 1);
    for(int i = 1; i <= n; i++)
        printf("%d ", ans[i]);
    printf("\n");
}


//wtf is this
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ll> point;
const int MAXN = 1e5 + 10;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

int N;
int ans[MAXN];
point P[MAXN];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		ll x, y;
		scanf("%lld %lld", &x, &y);
		P[i] = point(x, y);
	}

	while (true) {
		point loc(0, 0);
		for (int i = 0; i < N; i++) {
			point nxt1 = loc + P[i], nxt2 = loc - P[i];
			if (norm(nxt1) < norm(nxt2)) {
				ans[i] = 1;
				loc = nxt1;
			} else {
				ans[i] = -1;
				loc = nxt2;
			}
		}

		if (norm(loc) <= 2250000000000ll) {
			for (int i = 0; i < N; i++) {
				printf("%d ", ans[i]);
			}
			puts("");
			return 0;
		}
	}
}


//wtf is this
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ll> point;
const int MAXN = 1e5 + 10;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

int N;
int ans[MAXN];
point P[MAXN];

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		ll x, y;
		scanf("%lld %lld", &x, &y);
		P[i] = point(x, y);
	}

	while (true) {
		random_shuffle(P, P + N);
		point loc(0, 0);
		for (int i = 0; i < N; i++) {
			point nxt1 = loc + P[i], nxt2 = loc - P[i];
			if (norm(nxt1) < norm(nxt2)) {
				ans[i] = 1;
				loc = nxt1;
			} else {
				ans[i] = -1;
				loc = nxt2;
			}
		}

		if (norm(loc) <= 2250000000000ll) {
			for (int i = 0; i < N; i++) {
				printf("%d ", ans[i]);
			}
			puts("");
			return 0;
		}
	}
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ll> point;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

int N;

int main() {
	scanf("%d", &N);
	point loc(0, 0);
	for (int i = 0; i < N; i++) {
		ll x, y;
		scanf("%lld %lld", &x, &y);
		point p(x, y);
		point nxt1 = loc + p, nxt2 = loc - p;
		if (norm(nxt1) < norm(nxt2)) {
			printf("1 ");
			loc = nxt1;
		} else {
			printf("-1 ");
			loc = nxt2;
		}
	}
	puts("");
	assert(norm(loc) <= 2250000000000ll);
}


//wtf is this
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ll> point;
const int MAXN = 1e5 + 10;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

int N;
int ans[MAXN];
int fans[MAXN];
point P[MAXN];
multimap<pii, int> mpind;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		ll x, y;
		scanf("%lld %lld", &x, &y);
		P[i] = point(x, y);
		mpind.insert(make_pair(pii(x, y), i));
	}

	while (true) {
		random_shuffle(P, P + N);
		point loc(0, 0);
		for (int i = 0; i < N; i++) {
			point nxt1 = loc + P[i], nxt2 = loc - P[i];
			if (norm(nxt1) < norm(nxt2)) {
				ans[i] = 1;
				loc = nxt1;
			} else {
				ans[i] = -1;
				loc = nxt2;
			}
		}

		if (norm(loc) <= 2250000000000ll) {
			for (int i = 0; i < N; i++) {
				pii p(P[i].real(), P[i].imag());
				auto it = mpind.find(p);
				fans[it->se] = ans[i];
				mpind.erase(it);
			}
			for (int i = 0; i < N; i++) {
				printf("%d ", ans[i]);
			}
			puts("");
			return 0;
		}
	}
}


//wtf is this
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ll> point;
const int MAXN = 1e5 + 10;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))

int N;
int ans[MAXN];
int fans[MAXN];
point P[MAXN];
multimap<pii, int> mpind;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		ll x, y;
		scanf("%lld %lld", &x, &y);
		P[i] = point(x, y);
		mpind.insert(make_pair(pii(x, y), i));
	}

	while (true) {
		random_shuffle(P, P + N);
		point loc(0, 0);
		for (int i = 0; i < N; i++) {
			point nxt1 = loc + P[i], nxt2 = loc - P[i];
			if (norm(nxt1) < norm(nxt2)) {
				ans[i] = 1;
				loc = nxt1;
			} else {
				ans[i] = -1;
				loc = nxt2;
			}
		}

		if (norm(loc) <= 2250000000000ll) {
			for (int i = 0; i < N; i++) {
				pii p(P[i].real(), P[i].imag());
				auto it = mpind.find(p);
				fans[it->se] = ans[i];
				mpind.erase(it);
			}
			for (int i = 0; i < N; i++) {
				printf("%d ", fans[i]);
			}
			puts("");
			return 0;
		}
	}
}


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

struct point
{
    ll x,y,idx;
}p[100007], base;

int sign( point p, point q, point r )
{
    ll val= (q.y-p.y)*(r.x-q.x)-
            (q.x-p.x)*(r.y-q.y);

    val=-val;

    if(val==0)
        return 0;
    if(val<0)
        return 1;
    if(val>0)
        return 2;
}

ll dist( point a, point b )
{
    return ( a.x-b.x )*( a.x-b.x )+( a.y-b.y )*( a.y-b.y );
}

ll val( point a )
{
    return a.x*a.x+a.y*a.y;
}

bool cmp( point a, point b )
{
    if( a.x==b.x )
        return a.y<b.y;
    return a.x<b.x;
}

bool cmp2( point a, point b )
{
    int pos= sign( base, a, b );
    if( !pos )
    {
        ll d1= dist( base, a );
        ll d2= dist( base, b );

        return d1<d2;
    }

    return pos==2;
}

int main()
{
    base.x= 0;
    base.y= 0;

    int n;
    scanf("%d", &n);

    for(int i=0;i<n;i++)
        scanf("%lld %lld", &p[i].x, &p[i].y),
        p[i].idx= i;

    sort( p, p+n, cmp );
    sort( p, p+n, cmp2 );

    int cnt= 1;
    int now= n-1;

    while( sign( base, p[now], p[now-1])==0 and now>0  )
        cnt++, now--;
    reverse( p+1, p+cnt );

    bool odd= 0;
    vector<int> ans(n);

    for(int i=0;i<n;i++)
    {
        point P, Q;
        P.x= p[i].x+base.x;
        P.y= p[i].y+base.y;
        Q.x= base.x-p[i].x;
        Q.y= base.x-p[i].y;

        if( val(P)<= val(Q) )
        {
            ans[ p[i].idx ]= 1;
            base.x+= p[i].x;
            base.y+= p[i].y;
        }

        else
        {
            ans[ p[i].idx ]= -1;
            base.x-= p[i].x;
            base.y-= p[i].y;
        }
    }

    for(int i=0;i<n;i++)
        printf("%d ", ans[i]);

}


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

struct point
{
    ll x,y,idx;
}p[100007], base;

int sign( point p, point q, point r )
{
    ll val= (q.y-p.y)*(r.x-q.x)-
            (q.x-p.x)*(r.y-q.y);

    val=-val;

    if(val==0)
        return 0;
    if(val<0)
        return 1;
    if(val>0)
        return 2;
}

ll dist( point a, point b )
{
    return ( a.x-b.x )*( a.x-b.x )+( a.y-b.y )*( a.y-b.y );
}

bool cmp( point a, point b )
{
    if( a.x==b.x )
        return a.y<b.y;
    return a.x<b.x;
}

bool cmp2( point a, point b )
{
    int pos= sign( base, a, b );
    if( !pos )
    {
        ll d1= dist( base, a );
        ll d2= dist( base, b );

        return d1<d2;
    }

    return pos==2;
}

int main()
{
    base.x= 0;
    base.y= 0;

    int n;
    scanf("%d", &n);

    for(int i=0;i<n;i++)
        scanf("%lld %lld", &p[i].x, &p[i].y),
        p[i].idx= i;

    sort( p, p+n, cmp );
    sort( p, p+n, cmp2 );

    int cnt= 1;
    int now= n-1;

    while( sign( base, p[now], p[now-1])==0 and now>0  )
        cnt++, now--;
    reverse( p+1, p+cnt );

    bool odd= 0;
    vector<int> ans(n);

    for(int i=0;i<n;i++)
    {
        if(odd)
        {
            ans[ p[i].idx ]= 1;
            odd= 0;
        }

        else
        {
            ans[ p[i].idx ]= -1;
            odd= 1;
        }
    }

    for(int i=0;i<n;i++)
        printf("%d ", ans[i]);

}


#include <bits/stdc++.h>
#define ll long long
#define inf 1500000LL
using namespace std;

struct point
{
    ll x,y,idx;
} p[100007], base;

int sign( point p, point q, point r )
{
    ll val= (q.y-p.y)*(r.x-q.x)-
            (q.x-p.x)*(r.y-q.y);

    val=-val;

    if(val==0)
        return 0;
    if(val<0)
        return 1;
    if(val>0)
        return 2;
}

ll dist( point a, point b )
{
    return ( a.x-b.x )*( a.x-b.x )+( a.y-b.y )*( a.y-b.y );
}

ll val( point a )
{
    return a.x*a.x+a.y*a.y;
}

bool cmp( point a, point b )
{
    if( a.x==b.x )
        return a.y<b.y;
    return a.x<b.x;
}

bool cmp2( point a, point b )
{
    int pos= sign( base, a, b );
    if( !pos )
    {
        ll d1= dist( base, a );
        ll d2= dist( base, b );

        return d1<d2;
    }

    return pos==2;
}

int main()
{
    base.x= 0;
    base.y= 0;

    int n;
    scanf("%d", &n);

    for(int i=0; i<n; i++)
        scanf("%lld %lld", &p[i].x, &p[i].y),
              p[i].idx= i;

    vector<int> ans(n);
    int cnt= 0;

    do
    {
        cnt++;
        random_shuffle( p, p+n );
        base.x= 0;
        base.y= 0;
        for(int i=0; i<n; i++)
        {
            point P, Q;
            P.x= p[i].x+base.x;
            P.y= p[i].y+base.y;
            Q.x= base.x-p[i].x;
            Q.y= base.x-p[i].y;

            if( val(P)<= val(Q) )
            {
                ans[ p[i].idx ]= 1;
                base.x+= p[i].x;
                base.y+= p[i].y;
            }

            else
            {
                ans[ p[i].idx ]= -1;
                base.x-= p[i].x;
                base.y-= p[i].y;
            }
        }

        if(val(base)<=inf*inf)
            for(int i=0; i<n; i++)
                printf("%d ", ans[i]);

    }
    while( val(base)>inf*inf );

}


#include <bits/stdc++.h>
#define ll long long
#define inf 1500000
using namespace std;

struct point
{
    ll x,y,idx;
} p[100007], base;

int sign( point p, point q, point r )
{
    ll val= (q.y-p.y)*(r.x-q.x)-
            (q.x-p.x)*(r.y-q.y);

    val=-val;

    if(val==0)
        return 0;
    if(val<0)
        return 1;
    if(val>0)
        return 2;
}

ll dist( point a, point b )
{
    return ( a.x-b.x )*( a.x-b.x )+( a.y-b.y )*( a.y-b.y );
}

ll val( point a )
{
    return a.x*a.x+a.y*a.y;
}

bool cmp( point a, point b )
{
    if( a.x==b.x )
        return a.y<b.y;
    return a.x<b.x;
}

bool cmp2( point a, point b )
{
    int pos= sign( base, a, b );
    if( !pos )
    {
        ll d1= dist( base, a );
        ll d2= dist( base, b );

        return d1<d2;
    }

    return pos==2;
}

int main()
{
    base.x= 0;
    base.y= 0;

    int n;
    scanf("%d", &n);

    for(int i=0; i<n; i++)
        scanf("%lld %lld", &p[i].x, &p[i].y),
              p[i].idx= i;

    vector<int> ans(n);

    do
    {
        random_shuffle( p, p+n );
        for(int i=0; i<n; i++)
        {
            point P, Q;
            P.x= p[i].x+base.x;
            P.y= p[i].y+base.y;
            Q.x= base.x-p[i].x;
            Q.y= base.x-p[i].y;

            if( val(P)<= val(Q) )
            {
                ans[ p[i].idx ]= 1;
                base.x+= p[i].x;
                base.y+= p[i].y;
            }

            else
            {
                ans[ p[i].idx ]= -1;
                base.x-= p[i].x;
                base.y-= p[i].y;
            }
        }

        if(val(base)<=inf)
            for(int i=0; i<n; i++)
                printf("%d ", ans[i]);
        else
            ans.clear();
    }
    while( val(base)>inf );

}


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

struct point
{
    double x,y;
}p[100007];

bool operator == ( point a, point b )
{
    return a.x==b.x and a.y==b.y;
}

bool operator < ( point a, point b )
{
    return ( a.x*a.x+a.y*a.y ) > ( b.x*b.x+b.y*b.y );
}

int main()
{
    int n;
    scanf("%d", &n);

    for(int i=0;i<n;i++)
        scanf("%lld %lld", &p[i].x, &p[i].y);

    sort( p, p+n );

    bool odd= 1;

    for(int i=0;i<n;i++)
    {
        if( odd )
        {
            odd= 0;
            printf( "1 " );
        }

        else
        {
            odd= 1;
            printf( "-1 " );
        }
    }
}


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

struct point
{
    ll x,y,idx;
}p[100007], base;

int sign( point p, point q, point r )
{
    ll val= (q.y-p.y)*(r.x-q.x)-
            (q.x-p.x)*(r.y-q.y);

    val=-val;

    if(val==0)
        return 0;
    if(val<0)
        return 1;
    if(val>0)
        return 2;
}

ll dist( point a, point b )
{
    return ( a.x-b.x )*( a.x-b.x )+( a.y-b.y )*( a.y-b.y );
}

bool cmp( point a, point b )
{
    if( a.x==b.x )
        return a.y<b.y;
    return a.x<b.x;
}

bool cmp2( point a, point b )
{
    int pos= sign( base, a, b );
    if( !pos )
    {
        ll d1= dist( base, a );
        ll d2= dist( base, b );

        return d1<d2;
    }

    return pos==2;
}

int main()
{
    base.x= 0;
    base.y= 0;

    int n;
    scanf("%d", &n);

    for(int i=0;i<n;i++)
        scanf("%lld %lld", &p[i].x, &p[i].y),
        p[i].idx= i;

    sort( p, p+n, cmp );
    sort( p, p+n, cmp2 );

    int cnt= 1;
    int now= n-1;

    while( sign( base, p[now], p[now-1])==0 and now>0  )
        cnt++, now--;
    reverse( p+1, p+cnt );

    bool odd= 0;
    vector<int> ans(n);

    for(int i=0;i<n;i++)
    {
        point P, Q;
        P.x= p[i].x+base.x;
        P.y= p[i].y+base.y;
        Q.x= base.x-p[i].x;
        Q.y= base.x-p[i].y;

        if( dist(base, P)< dist(base, Q) )
        {
            ans[ p[i].idx ]= 1;
            base.x+= p[i].x;
            base.y+= p[i].y;
        }

        else
        {
            ans[ p[i].idx ]= -1;
            base.x-= p[i].x;
            base.y-= p[i].y;
        }
    }

    for(int i=0;i<n;i++)
        printf("%d ", ans[i]);

}


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

struct point
{
    ll x,y,idx;
}p[100007], base;

int sign( point p, point q, point r )
{
    ll val= (q.y-p.y)*(r.x-q.x)-
            (q.x-p.x)*(r.y-q.y);

    val=-val;

    if(val==0)
        return 0;
    if(val<0)
        return 1;
    if(val>0)
        return 2;
}

ll dist( point a, point b )
{
    return ( a.x-b.x )*( a.x-b.x )+( a.y-b.y )*( a.y-b.y );
}

ll val( point a, point b )
{
    return a.x*a.x+b.x*b.x;
}

bool cmp( point a, point b )
{
    if( a.x==b.x )
        return a.y<b.y;
    return a.x<b.x;
}

bool cmp2( point a, point b )
{
    int pos= sign( base, a, b );
    if( !pos )
    {
        ll d1= dist( base, a );
        ll d2= dist( base, b );

        return d1<d2;
    }

    return pos==2;
}

int main()
{
    base.x= 0;
    base.y= 0;

    int n;
    scanf("%d", &n);

    for(int i=0;i<n;i++)
        scanf("%lld %lld", &p[i].x, &p[i].y),
        p[i].idx= i;

    sort( p, p+n, cmp );
    sort( p, p+n, cmp2 );

    int cnt= 1;
    int now= n-1;

    while( sign( base, p[now], p[now-1])==0 and now>0  )
        cnt++, now--;
    reverse( p+1, p+cnt );

    bool odd= 0;
    vector<int> ans(n);

    for(int i=0;i<n;i++)
    {
        point P, Q;
        P.x= p[i].x+base.x;
        P.y= p[i].y+base.y;
        Q.x= base.x-p[i].x;
        Q.y= base.x-p[i].y;

        if( val(base, P)<= val(base, Q) )
        {
            ans[ p[i].idx ]= 1;
            base.x+= p[i].x;
            base.y+= p[i].y;
        }

        else
        {
            ans[ p[i].idx ]= -1;
            base.x-= p[i].x;
            base.y-= p[i].y;
        }
    }

    for(int i=0;i<n;i++)
        printf("%d ", ans[i]);

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
struct point{
	double x ,  y;
};
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
 // freopen("input.txt" , "r" , stdin);

  int n , f , prevf;
  cin>>n;
  point a[n];
  for(int i = 0 ; i <n ; i++)
   	   cin>>a[i].x>>a[i].y;
     int c[n];
	double x , y , s , dis1, dis2;

        c[0] = 1;
        x = a[0].x;
        y = a[0].y;

        for(int i = 1 ; i <n ; i++)
        {
        	dis1 = dis(x + a[i].x , y + a[i].y);
        	dis2 = dis(x - a[i].x , y - a[i].y);
        	if(dis1 < dis2)
        	x += a[i].x , y+=a[i].y , c[i] = 1;
        	else
        	x -= a[i].x , y-=a[i].y , c[i] = -1;
		}
       s = dis(x , y);
      //debug(s);
      if(s <= 1500000.00)
      {
      	for(int i = 0 ; i <n ; i++) cout<<c[i]<<" ";
      	return 0;
	  }
	  while(1)
	 {
	    for(int i = 0 ; i <n ; i++)
	    {
	  	   if(c[i] == 1)
	  	    {
	  	    	dis1 = dis(x- a[i].x - a[i].x , y - a[i].y - a[i].y);
	  	    	if(dis1 < s)
	  	    	c[i] = -1 , s = dis1 , x -=(a[i].x + a[i].x) , y -=(a[i].y + a[i].y);
	  	    	if(s <= 1500000.00) break;
			  }
			  else
			  {
			  		dis1 = dis(x+ a[i].x + a[i].x , y + a[i].y + a[i].y);
	  	         	if(dis1 < s)
	  	    	    c[i] = 1 , s = dis1  ,  x +=(a[i].x + a[i].x) , y +=(a[i].y + a[i].y);
	  	    	   	if(s <= 1500000.00) break;
			  }
	    }
	    debug(s);
	    if(s <= 1500000.00)
	    {
	    	for(int i = 0 ; i <n ; i++) cout<<c[i]<<" ";
      	     return 0;
		}
	}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
struct point{
	double x ,  y;
};
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
  //freopen("input.txt" , "r" , stdin);

  int n , f , prevf;
  cin>>n;
  point a[n+1] ;
  for(int i = 1 ; i <=n ; i++)
   	   cin>>a[i].x>>a[i].y;

    pair < double , double > dp[n+1][2] ;
    vector < double > v;
	double ans[n+1][2] , dis10 , dis11 , s;

   while(1)
   {
	 dp[0][0] = {0, 0};
     dp[0][1] = {0 , 0};
    f = 1;
    for(int i = 1 ; i<=n  ; i++)
    {
       dis10 = dis( dp[i-1][0].ff + a[i].x , dp[i-1][0].ss + a[i].y);
       dis11 = dis( dp[i-1][1].ff + a[i].x , dp[i-1][1].ss + a[i].y);
       if(dis10 <= dis11)
       dp[i][0] = {dp[i-1][0].ff + a[i].x , dp[i-1][0].ss + a[i].y} , ans[i][0] = 1;
       else
       dp[i][0] = {dp[i-1][1].ff + a[i].x , dp[i-1][1].ss + a[i].y} , ans[i][0] = -1;

       dis10 = dis( dp[i-1][0].ff - a[i].x , dp[i-1][0].ss - a[i].y);
       dis11 = dis( dp[i-1][1].ff - a[i].x , dp[i-1][1].ss - a[i].y);
       if(dis10 <= dis11)
       dp[i][1] = {dp[i-1][0].ff - a[i].x , dp[i-1][0].ss - a[i].y} , ans[i][1] = 1;
       else
       dp[i][1] = {dp[i-1][1].ff - a[i].x , dp[i-1][1].ss - a[i].y} , ans[i][1] = -1;

	}

           dis10 = dis(dp[n][0].ff , dp[n][0].ss);
          dis11 = dis(dp[n][1].ff , dp[n][1].ss);
       	  if(dis10 <= dis11)
       	  prevf = 0 , v.pb(1) , s = dis10;
       	  else
       	  prevf = 1 , v.pb(-1) , s = dis11;

	//debug(s);
    for(int i = n ; i>1 ; i--)
	{
	   f = ans[i][prevf];
	  v.pb(f) ;
	  prevf = (1-f)/2;
	}
	if(s <= 1500000)
	 {
	   for(int i = v.size()-1 ; i>=0 ; i--)
    	cout<<v[i]<<" ";
    	break;
      }
      else
      {
      	v.clear();
      	random_shuffle(a+1 , a+n+1);
	  }
   }

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
struct point{
	double x ,  y;
};
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
  //freopen("input.txt" , "r" , stdin);

  int n , f , prevf;
  cin>>n;
  point a[n+1] ;
  for(int i = 1 ; i <=n ; i++)
   	   cin>>a[i].x>>a[i].y;

    pair < double , double > dp[n+1][2] ;
    vector < double > v;
	double ans[n+1][2] , dis10 , dis11 , s;

   while(1)
   {
	 dp[0][0] = {0, 0};
     dp[0][1] = {0 , 0};
    f = 1;
    for(int i = 1 ; i<=n  ; i++)
    {
       dis10 = dis( dp[i-1][0].ff + a[i].x , dp[i-1][0].ss + a[i].y);
       dis11 = dis( dp[i-1][1].ff + a[i].x , dp[i-1][1].ss + a[i].y);
       if(dis10 <= dis11)
       dp[i][0] = {dp[i-1][0].ff + a[i].x , dp[i-1][0].ss + a[i].y} , ans[i][0] = 1;
       else
       dp[i][0] = {dp[i-1][1].ff + a[i].x , dp[i-1][1].ss + a[i].y} , ans[i][0] = -1;

       dis10 = dis( dp[i-1][0].ff - a[i].x , dp[i-1][0].ss - a[i].y);
       dis11 = dis( dp[i-1][1].ff - a[i].x , dp[i-1][1].ss - a[i].y);
       if(dis10 <= dis11)
       dp[i][1] = {dp[i-1][0].ff - a[i].x , dp[i-1][0].ss - a[i].y} , ans[i][1] = 1;
       else
       dp[i][1] = {dp[i-1][1].ff - a[i].x , dp[i-1][1].ss - a[i].y} , ans[i][1] = -1;

	}

           dis10 = dis(dp[n][0].ff , dp[n][0].ss);
          dis11 = dis(dp[n][1].ff , dp[n][1].ss);
       	  if(dis10 <= dis11)
       	  prevf = 0 , v.pb(1) , s = dis10;
       	  else
       	  prevf = 1 , v.pb(-1) , s = dis11;

	//debug(s);
    for(int i = n ; i>1 ; i--)
	{
	   f = ans[i][prevf];
	  v.pb(f) ;
	  prevf = (1-f)/2;
	}
	if(s <= 1500000.00)
	 {
	   for(int i = v.size()-1 ; i>=0 ; i--)
    	cout<<v[i]<<" ";
    	break;
      }
      else
      {
      	v.clear();
      	random_shuffle(a+1 , a+n+1);
	  }
   }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
 // freopen("input.txt" , "r" , stdin);

  int n , f , prevf;
  cin>>n;
  double x[n+1] , y[n+1];
  for(int i = 1 ; i <=n ; i++)
   	   cin>>x[i]>>y[i];

    pair < double , double > dp[n+1][2] ;
	double ans[n+1][2] , dis10 , dis11;

    dp[0][0] = {0, 0};
    dp[0][1] = {0 , 0};
    f = 1;
    for(int i = 1 ; i<=n  ; i++)
    {
       dis10 = dis( dp[i-1][0].ff + x[i] , dp[i-1][0].ss + y[i]);
       dis11 = dis( dp[i-1][1].ff + x[i] , dp[i-1][1].ss + y[i]);
       if(dis10 <= dis11)
       dp[i][0] = {dp[i-1][0].ff + x[i] , dp[i-1][0].ss + y[i]} , ans[i][0] = 1;
       else
       dp[i][0] = {dp[i-1][1].ff + x[i] , dp[i-1][1].ss + y[i]} , ans[i][0] = -1;

       dis10 = dis( dp[i-1][0].ff - x[i] , dp[i-1][0].ss - y[i]);
       dis11 = dis( dp[i-1][1].ff - x[i] , dp[i-1][1].ss - y[i]);
       if(dis10 <= dis11)
       dp[i][1] = {dp[i-1][0].ff - x[i] , dp[i-1][0].ss - y[i]} , ans[i][1] = 1;
       else
       dp[i][1] = {dp[i-1][1].ff - x[i] , dp[i-1][1].ss - y[i]} , ans[i][1] = -1;

	}
		vec v;
           dis10 = dis(dp[n][0].ff , dp[n][0].ss);
          dis11 = dis(dp[n][1].ff , dp[n][1].ss);
       	  if(dis10 <= dis11)
       	  prevf = 0 , v.pb(1);
       	  else
       	  prevf = 1 , v.pb(-1);

    for(int i = n ; i>1 ; i--)
	{
	   f = ans[i][prevf];
	  v.pb(f) ;
	  prevf = (1-f)/2;
	}

	for(int i = v.size()-1 ; i>=0 ; i--)
	cout<<v[i]<<" ";

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
  //freopen("input.txt" , "r" , stdin);

  int n , f , prevf;
  cin>>n;
  double x[n+1] , y[n+1];
  for(int i = 1 ; i <=n ; i++)
   	   cin>>x[i]>>y[i];

    pair < double , double > dp[n+1][2] ;
	double ans[n+1][2] , dis10 , dis11;

    dp[0][0] = {0, 0};
    dp[0][1] = {0 , 0};
    f = 1;
    for(int i = 1 ; i<=n  ; i++)
    {
       dis10 = dis( dp[i-1][0].ff + x[i] , dp[i-1][0].ss + y[i]);
       dis11 = dis( dp[i-1][1].ff + x[i] , dp[i-1][1].ss + y[i]);
       if(dis10 <= dis11)
       dp[i][0] = {dp[i-1][0].ff + x[i] , dp[i-1][0].ss + y[i]} , ans[i][0] = 1;
       else
       dp[i][0] = {dp[i-1][1].ff + x[i] , dp[i-1][1].ss + y[i]} , ans[i][0] = -1;

       dis10 = dis( dp[i-1][0].ff - x[i] , dp[i-1][0].ss - y[i]);
       dis11 = dis( dp[i-1][1].ff - x[i] , dp[i-1][1].ss - y[i]);
       if(dis10 <= dis11)
       dp[i][1] = {dp[i-1][0].ff - x[i] , dp[i-1][0].ss - y[i]} , ans[i][1] = 1;
       else
       dp[i][1] = {dp[i-1][1].ff - x[i] , dp[i-1][1].ss - y[i]} , ans[i][1] = -1;

	}
           dis10 = dis(dp[n][0].ff , dp[n][0].ss);
          dis11 = dis(dp[n][1].ff , dp[n][1].ss);
       	  if(dis10 <= dis11)
       	  prevf = 0;
       	  else
       	  prevf = 1;
	vec v;
    for(int i = n ; i>0 ; i--)
	{
	   f = ans[i][prevf];
	   v.pb(f) ,  prevf = (1-f)/2;

	}

	for(int i = v.size()-1 ; i>=0 ; i--)
	cout<<v[i]<<" ";

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
struct point{
	double x ,  y;
};
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
  //freopen("input.txt" , "r" , stdin);

  int n , f , prevf;
  cin>>n;
  point a[n];
  for(int i = 0 ; i <n ; i++)
   	   cin>>a[i].x>>a[i].y;
     int c[n];
	double x , y , s , dis1, dis2;

        c[0] = 1;
        x = a[0].x;
        y = a[0].y;

        for(int i = 1 ; i <n ; i++)
        {
        	dis1 = dis(x + a[i].x , y + a[i].y);
        	dis2 = dis(x - a[i].x , y - a[i].y);
        	if(dis1 < dis2)
        	x += a[i].x , y+=a[i].y , c[i] = 1;
        	else
        	x -= a[i].x , y-=a[i].y , c[i] = -1;
		}
       s = dis(x , y);
      //debug(s);
      if(s <= 1500000.00)
      {
      	for(int i = 0 ; i <n ; i++) cout<<c[i]<<" ";
      	return 0;
	  }
	  while(1)
	 {
	    for(int i = 0 ; i <n ; i++)
	    {
	  	   if(c[i] == 1)
	  	    {
	  	    	dis1 = (x- a[i].x - a[i].x , y - a[i].y - a[i].y);
	  	    	if(dis1 < s)
	  	    	c[i] = -1 , s = dis1;
	  	    	if(s <= 1500000.00) break;
			  }
			  else
			  {
			  		dis1 = (x+ a[i].x + a[i].x , y + a[i].y + a[i].y);
	  	         	if(dis1 < s)
	  	    	    c[i] = 1 , s = dis1;
	  	    	   	if(s <= 1500000.00) break;
			  }
	    }

	    if(s <= 1500000.00)
	    {
	    	for(int i = 0 ; i <n ; i++) cout<<c[i]<<" ";
      	     return 0;
		}
	}

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
 // freopen("input.txt" , "r" , stdin);

  int n , f;
  cin>>n;
  double x[n] , y[n];
  for(int i = 0 ; i <n ; i++)
   	   cin>>x[i]>>y[i];

    pair < double , double > dp[n][2] ;
	double ans[n][2] , dis10 , dis11;

    ans[0][0] = 1;
    ans[0][1] = -1;
    dp[0][0] = {x[0] , y[0]};
    dp[0][1] = {-x[0] , -y[0]};
    f = 1;
    for(int i = 1 ; i<n  ; i++)
    {
       dis10 = dis( dp[i-1][0].ff + x[i] , dp[i-1][0].ss + y[i]);
       dis11 = dis( dp[i-1][1].ff + x[i] , dp[i-1][1].ss + y[i]);
       if(dis10 <= dis11)
       dp[i][0] = {dp[i-1][0].ff + x[i] , dp[i-1][0].ss + y[i]} , ans[i][0] = 1;
       else
       dp[i][0] = {dp[i-1][1].ff + x[i] , dp[i-1][1].ss + y[i]} , ans[i][0] = -1;

       dis10 = dis( dp[i-1][0].ff - x[i] , dp[i-1][0].ss - y[i]);
       dis11 = dis( dp[i-1][1].ff - x[i] , dp[i-1][1].ss - y[i]);
       if(dis10 <= dis11)
       dp[i][1] = {dp[i-1][0].ff - x[i] , dp[i-1][0].ss - y[i]} , ans[i][1] = 1;
       else
       dp[i][1] = {dp[i-1][1].ff - x[i] , dp[i-1][1].ss - y[i]} , ans[i][1] = -1;

       if(i == (n-1))
       {  dis10 = dis(dp[i][0].ff , dp[i][0].ss);
          dis11 = dis(dp[i][1].ff , dp[i][1].ss);
       	  if(dis10 <= dis11)
       	  f = 1;
       	  else
       	  f = -1;
	   }
	}
	vec v;
	v.pb(f);
	for(int i = n-1 ; i>0 ; i--)
	{
		if(f == -1)
		f = ans[i][1] , v.pb(f);
		else
		f = ans[i][0] , v.pb(f);
	}

	for(int i = v.size()-1 ; i>=0 ; i--)
	cout<<v[i]<<" ";

}


#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define inf 1e+18
#define debug(x)   cerr<<#x<<": "<<x<<endl
struct point{
	double x ,  y;
};
double  dis(double x , double y)
{
	double ans = sqrt(x*x + y*y);
	return ans;
}
signed main()
{
  fast;
  //freopen("input.txt" , "r" , stdin);

  int n , f , prevf;
  cin>>n;
  point a[n];
  for(int i = 0 ; i <n ; i++)
   	   cin>>a[i].x>>a[i].y;
     int c[n];
	double x , y , s , dis1, dis2;

   while(1)
   {
        c[0] = 1;
        x = a[0].x;
        y = a[0].y;

        for(int i = 1 ; i <=n ; i++)
        {
        	dis1 = dis(x + a[i].x , y + a[i].y);
        	dis2 = dis(x - a[i].x , y - a[i].y);
        	if(dis1 < dis2)
        	x += a[i].x , y+=a[i].y , c[i] = 1;
        	else
        	x -= a[i].x , y-=a[i].y , c[i] = -1;
		}
       s = dis(x , y);

	if(s <= 1500000.00)
	 {
	   for(int i = 0 ; i < n ; i++)
    	cout<<c[i]<<" ";
    	break;
      }
      else
      	random_shuffle(a , a+n);
   }

    return 0;
}


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

typedef long long  ll;
typedef unsigned long long  ull;

#define PI              3.14159265359
#define oo              1e12
#define sc(x)           scanf("%d",&x)
#define sc2(x , y)      scanf("%d%d",&x , &y)
#define MOD             1000000007
#define fin              return 0
#define F                first
#define S                second
#define all(x)           x.begin(),x.end()
#define loop(i,n)        for(int i=0;i<n;i++)
#define lop(i,n)         for(int i=1;i<=n;i++)
#define loopv(i,n)       for(int i=n-1;i>=0;i--)
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
int xChange[] = {0, 1, 0, -1};
int yChange[] = {1, 0, -1, 0};
/*
ll conv_to_num(string s){
stringstream ss;
ss<<s;
ll f;
ss>>f;
return f;
}
string conv_to_string(ll s){
stringstream ss;
ss<<s;
string f;
ss>>f;
return f;
}
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
bool compare(const pair<ll, ll>&i, const pair<ll, ll>&j){
}
*/
const int N = 10005;
int a[N] , ans  , n;
map<int , bool>mp;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout
    ios::sync_with_stdio(false), cin.tie(NULL);

    cin >> n ;
    ll ss = 0 , s ;
    loop(i,n) cin >> a[i];
    for(int i = 0 ; i<n ; i++){
        s = a[i];
        for(int j = 0 ; j<n ; j++){
            if(i == j || mp[a[i]])continue;
            ss+=a[j];
            if((s + ss)%3 == 0 && !mp[a[j]]){
                mp[a[i]]=true;
                mp[a[j]]=true;
                ans++;
                break;
            }
           ss = 0;
        }
    }
    cout << ans;

return 0;
}


#from dust i have come dust i will be

n=int(input())
a=list(map(int,input().split()))

x=0
y=0
z=0

for i in range(n):
    if a[i]%3==0:
        x+=1
    elif a[i]%3==1:
        y+=1
    else:
        z+=1

t=(x//2)+min(y,z)
print(t)


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

int main()
{
int n;
scanf("%d",&n);
int a[5]={0},b;
for(int i=0;i<n;i++)
{
    scanf("%d",&b);
    a[b%3]++;
}
int ans=a[0]/2+min(a[1],a[2]);
printf("%d\n",ans);
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long sum;
    int x,y,i=0,j=0;
    cin>>x;
    int a[x],s[x];
    for(i=0;i<x;i++)
    {
        cin>>a[i];
    }
    i=0;
    fill_n(s,x,1);
    while(i<x)
    {
        s[i]*=10;
        if(s[i]<=a[i])
        i++;
    }
    for(i=0;i<x-1;i++)
    {
        sum=(long long)(a[i]*s[i+1]+a[i+1])%3;
        if(sum==0)
            {
                j++;
                i++;
            }
            if(i<x/2)
            {
                cout<<j;
                return 0;
            }
    }
    cout<<j;
}


 /*

       ____     ______                  _________       ___                ___
      /         |    |   \          /       |          |   \       |      |   |
     /          |    |    \        /        |          |    \      |      |___|
    /           |    |     \      /         |          |     \     |          |
    \           |    |      \    /          |          |     /     |          |
     \          |    |       \  /           |          |    /      |          |
      \_____    |____|        \/        ____|_____     |___/       |       ___|

*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,n,m) for(int i=n;i<m;i++)
#define pre(i,n,m) for(int i=n-1;i>=m;i--)
#define vii vector<int>
#define vi vector<vii>
#define pi pair<int,int>
#define mi unordered_map<int,int>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(xx) (int)xx.size()
#define all(yy) yy.begin(),yy.end()
#define rall(yyy) yyy.rbegin()+1,yyy.rend()
#define f first
#define s second
#define ll long long
#define hell 100000000000LL
#define callable 998244353
const int mod=1e9+7;
const int MAXN=1e5+100;
void solve()
{
	int hash[3],n;
	cin>>n;
	rep(i,0,n)
	{
		int x;
		cin>>x;
		++hash[x%3];
	}
	int ok=hash[0]/2+min(hash[1],hash[2]);
	cout<<ok<<endl;
}
int main()
{   fast
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


 /*

       ____     ______                  _________       ___                ___
      /         |    |   \          /       |          |   \       |      |   |
     /          |    |    \        /        |          |    \      |      |___|
    /           |    |     \      /         |          |     \     |          |
    \           |    |      \    /          |          |     /     |          |
     \          |    |       \  /           |          |    /      |          |
      \_____    |____|        \/        ____|_____     |___/       |       ___|

*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0);
#define rep(i,n,m) for(int i=n;i<m;i++)
#define pre(i,n,m) for(int i=n-1;i>=m;i--)
#define vii vector<int>
#define vi vector<vii>
#define pi pair<int,int>
#define mi unordered_map<int,int>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(xx) (int)xx.size()
#define all(yy) yy.begin(),yy.end()
#define rall(yyy) yyy.rbegin()+1,yyy.rend()
#define f first
#define s second
#define ll long long
#define hell 100000000000LL
#define callable 998244353
const int mod=1e9+7;
const int MAXN=1e5+100;
void solve()
{
	ll hash[3],n;
	memset(hash,0,sizeof(hash));
	cin>>n;
	rep(i,0,n)
	{
		ll x;
		cin>>x;
		++hash[x%3];
	}
	int ok=hash[0]/2+min(hash[1],hash[2]);
	cout<<ok<<endl;
}
int main()
{   fast
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
int v[5];
int main()
{
    int n,x,i;
    cin>>n;
    for(i=1;i<=n;++i)
        cin>>x,v[x%3]++;
    cout<<v[0]/2+abs(v[1]-v[2]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
int v[5];
int main()
{
    int n,x,i;
    cin>>n;
    for(i=1;i<=n;++i)
        cin>>x,v[x%3]++;
    cout<<v[0]/2+min(v[1],v[2]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
bitset <50005> f;
int ans[10005];
int main()
{
    int n,i,x,cnt=1;
    cin>>n;
    if(n==1)
    {
        cin>>x,cout<<"1";
        return 0;
    }
    for(i=1;i<=n;++i)
    {
        cin>>x;
        if(f[x]==0&&x<=n)
            f[x]=1,ans[i]=x;
    }
    int ok=0;
    for(i=1;i<=n;++i)
        if(ans[i]==0)
        {
            while(f[cnt]==1)
                ++cnt;
            ans[i]=cnt;
            ++cnt;
        }
    for(i=1;i<=n;++i)
        cout<<ans[i]<<" ";
    return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define SPEEDUP ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define pii pair <int,int>
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));
#define gcd(a,b) __gcd(a,b)

#define rep(i,n,x) for(i=0;i<n;i+=x)

typedef long long ll;

#define INF 2147483647

using namespace std;

int main()
{
    int n,c[3];cin >> n;
    c[0]=c[1]=c[2]=0;
    while(n--) {
        int a;cin>>a;c[a%3]++;

    }
    cout << c[0]/2+min(c[1],c[2]);
    return 0;
}


/*   Ekla Cholo Re   */

#include<iostream>
#include<sstream>
#include<iterator>
#include<vector>
#include<stack>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<list>
#include<string>
#include<algorithm>
#include<utility>
#include<queue>
#include<cstdio>
#include<ctype.h>
#include<cmath>

//macros..

#define SPEEDUP ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(s) (s).begin(),(s).end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define vi vector <int>
#define vll vector <long long>
#define vc vector <char>
#define vs vector <string>
#define vpi vector < pair <int,int> >
#define vps vector < pair <string,string> >
#define pii pair <int,int>
#define nl printf("\n");
#define ms(arr) memset(arr,0,sizeof(arr));
#define ms1(arr) memset(arr,1,sizeof(arr));
#define msn1(arr) memset(arr,-1,sizeof(arr));
#define gcd(a,b) __gcd(a,b)

#define rep(i,n,x) for(i=0;i<n;i+=x)

typedef long long ll;

#define INF 2147483647

using namespace std;

bool check(string s) {
    int sum=0;
    for(int i=0;i<s.length();++i) {
        sum += s[i]-'0';
    }
    return sum%3==0;
}

int main()
{
    unordered_map <string,bool> seen,part;
    int n,i,j;cin >> n;
    vs vec;
    rep(i,n,1) {
        string s;cin>>s;vec.pb(s);
    }
    int cnt=0;
    for(i=0;i<n;++i) {
        for(j=0;j<n;j++)
        {
            string s ="";
            if(i!=j) {

               s += vec[i];s+=vec[j];

               if(!seen[s] && !part[vec[i]] && !part[vec[j]]) cnt += check(s);
               if(check(s)) {part[vec[i]]=true,part[vec[j]]=true;}
               seen[s]=true;
            }
        }

    }

    cout << cnt;
    return 0;
}


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

#define ll long long int
#define mod 1e9+7
#define fo(i,a,b) \
    for(int i = a; i < b; i++)
#define fastio \
    ios_base::sync_with_stdio(0); \
    cin.tie(0); \
    cout.tie(0);

void solve() {
    int n;
    cin >> n;
    int a[]={0,0,0};
    fo(i,0,n) {
        ll x;
        cin >> x;
        if(x%3==1) {
            a[0]++;
        }
        else if(x%3==2) {
            a[1]++;
        }
        else {
            a[2]++;
        }
    }
    cout << min(a[0],a[1])+a[2]/2;
}

int main() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    fastio;

    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
        cout << '\n';
    }

    return 0;
}


#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;

}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int sumofdigits(int n){
    int sum = 0;
    while (n!=0)
    {
        sum=sum+n%10;
        n=n/ 10;
    }
    return sum;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int a[n];
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%3==1)x++;
        else if(a[i]%3==2)y++;
        else z++;
    }
    int count=min(x,y);
    count+=z/2;
    cout<<count;
    return 0;
}


#include <bits/stdc++.h>
#define ROCK ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define sec second
using namespace std;
typedef long long ll;
const long long int linf =(ll)9e18;
const int dx[8] = { 0, 0, 1, -1, 1, -1, 1, -1 }, dy[8] = { 1, -1, 0, 0, 1, -1, -1, 1 };

int main()
{
    ROCK;
    int n;cin>>n;
    map<int,int>mp;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        mp[x%3]++;
    }cout<<(mp[0]/2 + min(mp[1],mp[2]))<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;
typedef long double ld;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.second < b.second) return true;
        if(a.second == b.second) return a.first < b.first;
        return false;
}
bool isprime(int n)
{
    // Corner case
    if (n <= 1)
        return false;

    // Check from 2 to n-1
    for (int i = 2; i <=sqrt(n); i++)
        if (n % i == 0)
            return false;

    return true;
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int k;
    //cin>>k;
    k=1;
    while(k--)
    {
        int n;
        cin>>n;
        int a[n],b[3];
        FOR(i,0,n)cin>>a[i];
        FOR(i,0,3)b[i]=0;
        for(int i=0;i<n;i++)
        {
            int p=0;
            while(a[i])
            {
                p=p+(a[i]%10);
                a[i]/=10;
            }
            p=p%3;
            b[p]++;
        }
        int ans=0;
        ans=min(b[1],b[2]);
        ans=ans+(b[0]/2);
        cout<<ans;
    }
	return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

    int n , a(0),b(0),c(0) ;
    long x ;

    while(n--)
    {
        cin>> x;
        if(x%3 == 0)
            a++;
        else if ( x%3 == 1)
            b++;
        else if ( x%2 == 2)
            c++;

    }
    cout << long ans = a/2 + min(a,b);
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

    int n , a(0),b(0),c(0) ;
    cin >> n ;
    long x ;

    while(n--)
    {
        cin>> x;
        if(x%3 == 0)
            a++;
        else if ( x%3 == 1)
            b++;
        else if ( x%2 == 2)
            c++;

    }
    long ans =  a/2 + min(b,c);
    cout << ans ;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

    int n , a(0),b(0),c(0) ;
    long x ;

    while(n--)
    {
        cin>> x;
        if(x%3 == 0)
            a++;
        else if ( x%3 == 1)
            b++;
        else if ( x%2 == 2)
            c++;

    }
    cout << a/2 + min(b,c);
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

    int n , a(0),b(0),c(0) ;
    cin >> n ;
    long x ;

    while(n--)
    {
        cin>> x;
        if(x%3 == 0)
            a++;
        else if ( x%3 == 1)
            b++;
        else if ( x%3 == 2)
            c++;

    }
    long ans =  a/2 + min(b,c);
    cout << a<<b<<c <<""<<ans ;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n ;
    int t = 0 ;
    cin >> n ;
    string a[n] ;

    for ( int i = 0 ; i < n ; i++)
    {
        cin>> a[n] ;
    }

    for ( int i = 0 ; i < n ; i++)
    {
       for ( int j = i ; j < n ; j++)
       {
           long long l = stol(a[i]+a[j])  ;
           if(l % 3 == 0 && a[i] != "" && a[j] != "")
           {
               t++;
               a[i]="" ;
               a[j] = "";

           }
       }
    }

    cout << t ;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

    int n , a(0),b(0),c(0) ;
    cin >> n ;
    long x ;

    while(n--)
    {
        cin>> x;
        if(x%3 == 0)
            a++;
        else if ( x%3 == 1)
            b++;
        else if ( x%3 == 2)
            c++;

    }
    long ans =  a/2 + min(b,c);
    cout << ans ;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

    int n , a(0),b(0),c(0) ;
    long x ;

    while(n--)
    {
        cin>> x;
        if(x%3 == 0)
            a++;
        else if ( x%3 == 1)
            b++;
        else if ( x%2 == 2)
            c++;

    }
    cout << a/2 + min(a,b);
    return 0;
}


#include <iostream>
#include <string>
using namespace std;

int main()
{

    int n , a(0),b(0),c(0) ;
    long x ;

    while(n--)
    {
        cin>> x;
        if(x%3 == 0)
            a++;
        else if ( x%3 == 1)
            b++;
        else if ( x%2 == 2)
            c++;

        cout << a/2 + min(a,b);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<string>
#include<algorithm>
#include<stack>
#include<limits.h>
#include<numeric>
#include<map>
#include<vector>
#include<queue>
#define ll long long
#define str string
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define vec vector<int>
#define long_vec vector<ll>
#define out cout<<
#define in cin>>
#define rep(a,b) for(int i=a;i<b;i++)
#define repl(a,b) for(ll i=a;i<b;i++)
#define nl cout<<endl;
#define sortv(v) sort(v.begin(),v.end())
#define ret return 0;
#define countr(v,a) (int)count(v.begin(),v.end(),a)
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define start int main()
using namespace std;
start
{
    ll n;
    in n;
    ll inp;
    long_vec v,temp;
    rep(0, n)
    {
        ll sum=0;
        in inp;
        string s=to_string(inp);
        for(int j=0;j<s.length();j++)
        {
            sum+=s[j]-'0';
        }
        v.push_back(sum);
        temp.push_back(0);
    }
    int counter=0;
    for(int i=0;i<v.size()-1;i++)
    {
        if(temp[i]==0){
        for(int j=i+1;j<v.size();j++)
        {
            if(temp[j]==0){
            if((v[i]+v[j])%3==0)
            {
                temp[i]=1;
                temp[j]=1;
                counter++;
                break;
            }
            }
        }
        }
    }
    out counter;
   /* vector<pair<ll,ll>> v;
    long_vec w;
    pair<ll,ll> p;
    repl(0,n)
    {
        in inp;
        w.push_back(inp);
        int sum=0;
        string s=to_string(inp);
        for(int j=0;j<s.length();j++)
        {
                sum+=s[j]-'0';
        }
        //out "inp "<<inp <<" sum "<<sum;nl
        v.push_back(make_pair(inp, sum));

    }
    int counter=0;
    for(int i=0;i<v.size();i++)
    {
        int a=0;
        for(int j=0;j<v.size();j++)
        {
            if(i!=j){
            if((v[i].second+v[j].second)%3==0)
            {
                //out v[i].second <<" "<<v[j].second;nl
                a=1;
                counter++;
                if(j>i){

                    v.erase(v.begin()+j);
                v.erase(v.begin()+i);}
                else
                {
                    v.erase(v.begin()+i);
                    v.erase(v.begin()+j);}
                break;
            }
            }
        }
        for(int k=0;k<v.size();k++)
        {
            out v[k].first<<" "<<v[k].second<<" ";
            nl
            }
            nl

        if(a==0)
        {
            v.erase(v.begin()+i);
        }
    }
    out counter;*/

}


#include<iostream>
#include<cstring>
#include<stdio.h>
#include<iomanip>
#include<math.h>
#include<string>
#include<algorithm>
#include<stack>
#include<limits.h>
#include<numeric>
#include<map>
#include<vector>
#include<queue>
#define ll long long
#define str string
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define vec vector<int>
#define long_vec vector<ll>
#define out cout<<
#define in cin>>
#define rep(a,b) for(int i=a;i<b;i++)
#define repl(a,b) for(ll i=a;i<b;i++)
#define nl cout<<endl;
#define sortv(v) sort(v.begin(),v.end())
#define ret return 0;
#define countr(v,a) (int)count(v.begin(),v.end(),a)
#define FILL(a,b) memset((a),(b),sizeof((a)))
#define start int main()
using namespace std;
start
{
    ll n;
    in n;
    ll inp;
    vector<pair<ll,ll>> v;
    long_vec w;
    pair<ll,ll> p;
    repl(0,n)
    {
        in inp;
        w.push_back(inp);
        int sum=0;
        string s=to_string(inp);
        for(int j=0;j<s.length();j++)
        {
                sum+=s[j]-'0';
        }
        //out "inp "<<inp <<" sum "<<sum;nl
        v.push_back(make_pair(inp, sum));

    }
    int counter=0;
    for(int i=0;i<v.size();i++)
    {
        int a=0;
        for(int j=0;j<v.size();j++)
        {
            if(i!=j){
            if((v[i].second+v[j].second)%3==0)
            {
                //out v[i].second <<" "<<v[j].second;nl
                a=1;
                counter++;
                if(j>i){
                v.erase(v.begin()+i);
                    v.erase(v.begin()+j-1);}
                else
                {
                    v.erase(v.begin()+i);
                    v.erase(v.begin()+j);}
                break;
            }
            }
        }
        if(a==0)
        {
            v.erase(v.begin()+i);
        }
    }
    out counter;

}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "debug.hpp"
#endif
using namespace std;
int fun(int a) {

	int sum = 0;
	while (a) {

		sum += a % 10;
		a /= 10;

	}
	return sum;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<int> v(n);

	vector<bool> a(n, false);

	for (auto & x : v)
		cin >> x;

	int ans = 0;

	for (int i = 0; i < v.size(); i++) {

		if (!a[i])
			for (int j = i + 1; j < v.size(); j++) {

				if (!a[j] && (fun(v[i]) + fun(v[j])) % 3 == 0)
					ans++;
				a[j] = true;
				a[i] = true;
				break;
			}

	}

	cout << ans;

	return 0;
}


#include <bits/stdc++.h>
#if !defined(ONLINE_JUDGE)
#include "debug.hpp"
#endif
using namespace std;
int fun(int a) {

	int sum = 0;
	while (a) {

		sum += a % 10;
		a /= 10;

	}
	return sum;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	vector<int> v(n);

	int a[3] = {0};

	for (auto & x : v) {
		cin >> x;
		a[x % 3]++;
	}
	cout << a[0] / 2 + min(a[1], a[2]);

//	cout << ans;

	     return 0;
}


#include <iostream>
using namespace std;
int n,i,b,a[3];
int main(){
	       cin>>n;
	       for(i=0;i<n;i++){
	       	cin>>b;
	       	a[b%3]++;
		   }
		   cout<<a[0]/2+min(a[1],a[2]);
}


#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<int> >vii ;
typedef pair<int,int> pi ;
ll calc(vll v,int n, int x , int y , int a , int b)
{
    ll cxy,cx,cy ;
    cxy = cx = cy = 0 ;
    for(ll i=1 ; i<=n  ;i=i+1)
    {
        if(i%a==0 && i%b==0)
        {
            cxy++;
        }
        else if(i%a==0)
        {
            cx++ ;
        }
        else if(i%b==0)
        {
            cy++;
        }
    }
    double profit = 0 ;
    for(ll i=0 ; i<cxy  ;i=i+1)
    {
        profit = profit + 1.0*v[i+1]*((x+y)/100.0) ;
    }
    for(ll i=0 ;  i<cx  ;i=i+1)
    {
        profit = profit + 1.0*v[i+cxy]*((x)/100.0) ;
    }
    for(ll i=0 ;  i<cy  ;i=i+1)
    {
        profit = profit + 1.0*v[i+cxy+cx]*((y)/100.0) ;
    }
    return(profit) ;
}
void swap(ll &a,ll &b)
{
    ll temp = a ;
    a = b ;
    b = temp ;
}
int main()
{
    ios_base::sync_with_stdio(false);//this and next two lines for cin cout TLE handling
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,i,j,n,c,d,k,t,m,q,x,y,f;
    cin>>n ;
    vector<string>v ;
    string str,str1,str2;
    for(i=0 ; i<n ; i=i+1)
    {
        cin>>str ;
        v.pb(str) ;
    }
    c = 0 ;
    for(i=0 ; i<n ; i=i+1)
    {
        str1 = v[i] ;
        if(v[i].size()==0)
        {
            continue ;
        }
        for(j=i+1 ; j<n ; j=j+1)
        {
            if(v[j].size()==0)
            {
                continue ;
            }
            str2 = v[j] ;
            str = str1+str2 ;
            stringstream t1,t2 ;
            t1<<str;
            t1>>a ;
            if(a%3==0)
            {
                c++ ;
                v[i].clear();
                v[j].clear() ;
                break ;
            }
            str = str2+str1 ;
            t2<<str ;
            t2>>a ;
            if(a%3==0)
            {
                c++ ;
                v[i].clear();
                v[j].clear() ;
                break ;
            }
        }
    }
    cout<<c ;
}


#pragma GCC optimize("Ofast,unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
/*order_of_key(val): returns the no. of values less than val
find_by_order(k): returns the iterator to kth largest element.(0 - based)*/
typedef long double LD;
typedef long long ll;
#define int ll
#define pb push_back
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define sortall(x) sort(all(x))
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define PI 3.1415926535897932384626
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
#define F first
#define S second
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type,vector<type>,greater<type> >
#define WL(t) while(t --)
#define runtime() ((double)clock() / CLOCKS_PER_SEC)
#define sqr(x) ((x)*(x))
#define inrange(i,a,b) ((i>=min(a,b)) && (i<=max(a,b)))

#define si(x) scanf("%lld",&x)
#define ss(x) scanf("%s",s)

#define pi(x) printf("%lld\n",x)
#define ps(x) printf("%s",x)

#define deb(x) cout<<#x <<"="<< x<<endl
#define deb2(x,y) cout<<#x<<"="<<x<<"."<<#y<<"="<<y<<endl
#define FLUSH fflush(stdout)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"

const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double Pi = acos(-1);

#ifdef int
const int INF = 1e16;
#else
const int INF = 1e9;
#endif

const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;

template<typename T> T gcd(T a, T b) {return (b ? __gcd(a, b) : a);}
template<typename T> T lcm(T a, T b) {return (a * (b / gcd(a, b)));}
int add(int a, int b, int c = MOD) {int res = a + b; return (res >= c ? res - c : res);}
int mod_neg(int a, int b, int c = MOD) {int res; if (abs(a - b) < c)res = a - b; else res = (a - b) % c; return (res < 0 ? res + c : res);}
int mul(int a, int b, int c = MOD) {ll res = (ll)a * b; return (res >= c ? res % c : res);}
int muln(int a, int b, int c = MOD) {ll res = (ll)a * b; return ((res % c) + c) % c;}
ll mulmod(ll a, ll b, ll m = MOD) {ll q = (ll)(((LD)a * (LD)b) / (LD)m); ll r = a * b - q * m; if (r > m)r %= m; if (r < 0)r += m; return r;}
template<typename T>T expo(T e, T n) {T x = 1, p = e; while (n) {if (n & 1)x = x * p; p = p * p; n >>= 1;} return x;}
template<typename T>T power(T e, T n, T m = MOD) {T x = 1, p = e; while (n) {if (n & 1)x = mul(x, p, m); p = mul(p, p, m); n >>= 1;} return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y) {
	T xx = 0, yy = 1; y = 0; x = 1; while (b) {
		T q = a / b, t = b; b = a % b; a = t; \
		t = xx; xx = x - q * xx; x = t; t = yy; yy = y - q * yy; y = t;
	} return a;
}
template<typename T>T mod_inverse(T a, T n = MOD) {T x, y, z = 0; T d = extended_euclid(a, n, x, y); return (d > 1 ? -1 : mod_neg(x, z, n));}

signed main() {
	FAST_IO;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	int key;
	int  z = 0, one = 0, two = 0;
	REP(i, n) {
		cin >> key;
		int rem = key % 3 ;
		if (rem == 0 ) z++;
		else if (rem == 1) one++;
		else two++;
	}
	int ans = z / 2 + min(one, two);
	cout << ans << endl;

	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int getSum(int n)
{
   int sum = 0;
   while (n != 0)
   {
       sum = sum + n % 10;
       n = n/10;
   }
   return sum;
}

int main(){
    int n;
    cin>>n;
    int a=0,b=0,c=0,temp;
    for(int i=0;i<n;i++){
        cin>>temp;
        temp=getSum(temp)%3;
        if(temp==0)
            a++;
        else if(temp==1)
            b++;
        else
            c++;
    }
    cout<<floor(a/2)+min(b,c);
}


#include<bits/stdc++.h>
#define rep(i,start,lim) for(int i=start;i<lim;i++)
using namespace std;
#define N 100005
int freq[1100],tmp[1024];
int main()
{
    int n,k,maxm=0,minm=INT_MAX,p,x;
    cin>>n>>k>>x;
    rep(i,0,n) cin>>p,freq[p]++;
    rep(i,0,k)
    {
        rep(j,0,1024) tmp[j]=freq[j];
        int par=0;
        rep(j,0,1024)
        {
            if(freq[j]>0)
            {
                int curr = (j^x),change = (freq[j]/2);
                if(par==0) change+=(freq[j]&1);
                tmp[j]-=change;
                tmp[curr]+=change;
                par^=(freq[j]&1);
            }
        }
        rep(j,0,1024) freq[j]=tmp[j];
    }
    rep(i,0,1024) if(freq[i]>0) minm=min(minm,i),maxm=max(maxm,i);
    cout<<maxm<<" "<<minm;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, a[10001], i, ans1, ans0, ans2;
int main()
{
    cin>>n;
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]=a[i]%3;
    }
    for (i=0;i<n;i++)
    {
        if (a[i]==0) ans0++;
        if (a[i]==1) ans1++;
        if (a[i]==2) ans2++;
    }
    int cur=min(ans1, ans2);
    int ans=cur+ans0/2;
    cout<<ans<<endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n, a[10001], i, ans1, ans0, ans2;
int main()
{
    cin>>n;
    for (i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]=a[i]%3;
    }
    for (i=0;i<n;i++)
    {
        if (a[i]==0) ans0++;
        if (a[i]==1) ans1++;
        if (a[i]==2) ans2++;
    }
    int cur=min(ans1, ans2);
    int ans=cur/2+cur%2+ans0/2+ans0%2;
    cout<<ans/2<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define SLAY ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.141592653589793238
#define ll long long
#define pii pair<int , int>
#define pll pair<long long , long long>
#define INPUT freopen("inp.txt", "r", stdin);
using namespace std;
int dx[] = { 0 , 0 , 1 , -1};
int dy[] = { 1 , -1 , 0 , 0};
int getmod(int x, int y , int mod ){return (((x - y)%mod)+mod)%mod;}

// sieve
int MAXN = 46341 + 1;
int spf[46341+1];
int d,x,y;
int gcd(int a , int b){
	if(b==0)return a;
	return gcd(b , a%b);
}
void sieve(){
	for(int i = 1 ; i<MAXN ; i++)spf[i]=i;
	for(int i = 4 ; i<MAXN ; i+=2)spf[i]=2;
	for(int i = 3; i*i<MAXN; i+=2){
		if(spf[i]==i){
			for(int j = i*i ; j<MAXN ; j+=i){
				if(spf[j]==j)spf[j]=i;
			}
		}
	}
}

void extended_gcd(int a , int b){
	if(b==0){
		d=a;
		x=1;
		y=0;
	}else{
		extended_gcd(b,a%b);
		int temp = y;
		y = x - y * (a/b);
		x = temp;
	}
}
int main(){
	SLAY
	int _=1 , tc=1;
	// cin>>_;
	// sieve();
	ll n,m;
	while(_--){
		cin>>n;
		vector<int>v(3,0);
		for(int i=0;i<n;i++){
			int temp;
			cin>>temp;
			v[temp%3]++;
		}
		cout<<min(v[2],v[1]) + (v[0]/2);
		cout<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

    ll n,x,sum=0;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>x;
        while(x>0)
        {
            sum+=x%10;
            x/=10;
        }
        a[i]=sum;
        sum=0;
    }
    ll k=0;
    for(int i=0;i<a.size()-1;i++)
    {
        for(int j=i+1;j<a.size();j++)
        {
            if((a[i]+a[j])%3==0)
             {k++;a.erase(a.begin()+i);a.erase(a.begin()+j-1);break;}
        }
        //for(int i:a)
         // cout<<i<<" ";
          //cout<<endl;
    }
     cout<<k;
    return 0;

}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

    ll n,x,sum=0;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>x;
        while(x>0)
        {
            sum+=x%10;
            x/=10;
        }
        a[i]=sum;
        sum=0;
    }
    //for(int i:a)
     //cout<<i<<"  ";
    ///cout<<endl;
    ll k=0;
    for(int i=0;i<a.size()-1;i++)
    {
        for(int j=i+1;j<a.size();j++)
        {   //cout<<a[i]<<" "<<a[j]<<endl;
            if(a[i]>0 && a[j]>0 && (a[i]+a[j])%3==0)
             {k++;a[i]=-1;a[j]=-1;break;}
        }
        //for(int i=0;i<a.size();i++)
         // cout<<a[i]<<" ";
          //cout<<endl;
    }
     cout<<k;

    return 0;

}


#include<iostream>
using namespace std;
int sum(string s)
{
	int n = s.size();
	int ret=0;
	for(int i=n-1;i>=0;i--)
	{
		ret += (s[i]-'0');
	}
	return ret;
}
int h[3]={0};
int main()
{
	int n;
	cin>>n;
	string s;
	for(int i=0;i<n;i++)
	cin>>s,h[sum(s)%3]++;
	cout<<h[0]/2+min(h[1],h[2])<<"\n";
}


#include<iostream>
using namespace std;
int sum(string s)
{
	int n = s.size();
	int ret=0;
	for(int i=n-1;i>=0;i--)
	{
		ret += (s[i]-'0');
	}
	return ret;
}
int main()
{
	int n;
	cin>>n;
	string s;
	int arr[n];
	for(int i=0;i<n;i++)
	cin>>s,arr[i]=sum(s);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(arr[i]!=-1)
		for(int j=i+1;j<n;j++)
		if(arr[j]!=-1 && (arr[i]+arr[j])%3==0)
		{
			ans++,arr[i]=-1,arr[j]=-1;
			break;
		}
	}
	cout<<ans<<"\n";
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    vector <int> mod(3, 0);

    for(int i=0; i<n; i++)
    {
        string s;
        cin >> s;
        int suma = 0;
        for(auto i:s)
            suma += (i-'0');
        mod[suma%3]++;
    }

    cout << mod[0]/2 + min(mod[1], mod[2]) << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    if(n == 1 || m == 1)
    {
        if(n*m > 2)
            cout << 1 << endl << n << " " << m << " 1 1" << endl;
        else
            cout << 0 << endl;

        for(int i=1; i<=n; i++)
            for(int j=1; j<=m; j++)
                cout << i << " " << j << endl;
        cout << "1 1" << endl;
        return 0;
    }

    if(m%2 == 0)
        cout << 0 << endl;
    else
        cout << 1 << endl << n << " 1 1 1" << endl;

    for(int i=1; i<=m; i++)
        cout << 1 << " " << i << endl;
    int inc = 1;
    int pos = 2;
    for(int i=m; i>=1; i--)
    {
        while(2 <= pos && pos <= n)
        {
            cout << pos << " " << i << endl;
            pos += inc;
        }
        pos -= inc;
        inc *= (-1);
    }
    cout << "1 1" << endl;

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/

int main()
{
    ll n;
    cin>>n;
    ll A[n];
    map<ll,ll>mp;
    for(ll i = 0; i < n; i++){
        ll a;
        cin>>a;
        a = a % 3;
        mp[a]++;
    }
    cout<<max(min(mp[1],mp[2]),mp[0] / 2);
    return 0;

}


#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/

int main()
{
    ll n;
    cin>>n;
    map<ll,ll>mp;
    for(ll i = 0; i < n; i++){
        ll a;
        cin>>a;
        a = a % 3;
        mp[a]++;
    }
    cout<< min(mp[1],mp[2]) + mp[0] / 2;
    return 0;

}


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

long int sum(long int n)
{
    long int s=0;
    while(n!=0)
     {
         s+=n%10;
         n/=10;
     }

     return s;
}

int main() {

    int n;
    cin>>n;
    long int a[n],i,j,cnt=0;
    vector<long int> v;
    for(i=0;i<n;++i)
     {
         cin>>a[i];
         v.push_back(sum(a[i]));
     }

    for(i=0;i<v.size();++i)
     {
         if(v[i]!=-1)
         {
         for(j=i+1;j<v.size();++j)
           {
               if((v[i]+v[j])%3==0 && v[j]!=-1)
                  {
                      v[j]=-1;
                      cnt++;
                      break;
                  }
           }

         }

     }

     cout<<cnt;

	return 0;
}


#include <bits/stdc++.h>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define P acos(-1)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

int a, p[181], n, i;

    int S(int a)
    {
        int ans = 0;

        while (a > 0) {
            ans += a % 10;

            a /= 10;
        }

        return ans;
    }

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (i = 1; i <= n; i++) {
        cin >> a;

        p[S(a) % 3]++;
    }

    cout << p[0] / 2 + min(p[1], p[2]) << endl;

    return 0;
}


#include <bits/stdc++.h>

#define x0 abc
#define y0 ABC
#define x1 abcd
#define y1 ABCD
#define xn abcde
#define yn ABCDE

#define l_b lower_bound
#define u_b upper_bound

#define fi first
#define se second
#define m_p make_pair

#define p_b push_back
#define po_b pop_back

#define P acos(-1)

#define endl '\n'

#define OUT cout << "-------" << endl;

using namespace std;

int a, p[181], n, i;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (i = 1; i <= n; i++) {
        cin >> a;

        p[a % 3]++;
    }

    cout << p[0] / 2 + min(p[1], p[2]) << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int rem[3];
ll n,x;
main(){
	cin>>n;
	for(auto i=0;i<n;i++){
	    cin>>x;
	    rem[x%3]++;
	}

	cout << rem[0]/2 + min(rem[1],rem[2])<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int rem[3];
ll n,x;
main(){
	cin>>n;
	for(auto i=0;i<n;i++){
	    cin>>x;
	    rem[x%3]++;
	}

	cout << rem[0]/2 + min(rem[1],rem[1])<<endl;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e4 + 123;
const int PRI = 555557;
const int pri = 997;

int tests = 1;
int n, m, k;
int a[N];
int cnt[N];

inline void Solve () {
	//easy
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		cnt[a[i] % 3] ++;
	}

	cout << (cnt[0] / 2) + min(cnt[1], cnt[2]);
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted;
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

//#include<bits/stdc++.h>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define _USE_MATH_DEFINES
#define ll long long
#define ins Not Needed Thing
#define ull unsigned long long
#define ld long double
#define Accepted 0
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define SORRY FUL Accepted
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0)
#define Toktama Kazakhstan

using namespace std;

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 3e4 + 123;
const int PRI = 555557;
const int pri = 997;

int tests = 1;
int n, m, k;
int a[N];
int cnt[N];

inline void Solve () {
	//easy
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
		cnt[a[i] % 3] ++;
	}

	cout << (cnt[0] / 2) * 2 + min(cnt[1], cnt[2]);
}

int main () {
	SpeedForce;
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	// cin >> tests;
	while(tests --) {
		Solve ();
		// Ee Zadrot
	}

	return Accepted;
}


#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

#define sp system("pause")
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define FORll(i,a,b) for(ll i=a;i<b;++i)
#define FORD(i,a,b) for(int i=a;i>=b;--i)

#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,1,sizeof(x))
#define MSINF(x) memset(x,0x3f,sizeof(x))
#define SORT(a) sort(a.begin(),a.end())
#define MOD 1000000007
#define INF 0x3f3f3f3f

#define F first
#define S second

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
const int N = 2001;

int main()
{
    // FIO;
    ll T,n,m,k;
    // cin>>T;
    T=1;
    while(T--) {
        cin>>n;
        vi mod3(3,0);
        while(n--) {
            cin>>k;
            mod3[k%3]++;
        }
        int ans = mod3[0]/2 + min(mod3[1], mod3[2]);
        cout<<ans;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<cstring>
#include<algorithm>
using namespace std;

int a[10010];
int b[10010];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        map<int,int>s;
        for(int i=0; i<n; i++)
            scanf("%d",&a[i]);
        for(int i=0; i<n; i++)
        {
            b[i]=a[i]%3;
        }
        sort(b,b+n);
        for(int i=0; i<n; i++)
        {
            s[b[i]]++;
        }
        int cnt=0;
        cnt+=(s[0]/2);
        int k=min(s[1],s[2]);
        cnt+=(k);
        printf("%d\n",cnt);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<cstring>
#include<algorithm>
using namespace std;

int a[10010];
int b[10010];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        map<int,int>s;
        for(int i=0; i<n; i++)
            scanf("%d",&a[i]);
        for(int i=0; i<n; i++)
        {
            b[i]=a[i]%3;
        }
        sort(b,b+n);
        for(int i=0; i<n; i++)
        {
            s[b[i]]++;
        }
        int cnt=0;
        cnt+=(s[0]/2);
        int k=abs(s[1]-s[2]);
        cnt+=(k/2);
        printf("%d\n",cnt);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fill(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int cal(string str)
{
    int sum=0;
    for(int i=0;i<str.size();i++)
        sum+=(str[i]-'0');
    return sum;
}
int main()
{
   //  freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    int arr[3]={0};
    string str;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        int num=cal(str);
        arr[num%3]++;
    }
    int res=0;
    res+=arr[0]/2;
    res+=min(arr[1],arr[2]);
    cout<<res<<endl;
    return 0;

}


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

int getDigitSum(int n){
	int sum=0;
	while(n!=0){
		sum+=n%10;
		n/=10;
	}
return sum;
}

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	int c=0;
	multimap<int,int> mp;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(getDigitSum(a[i])%3==0){
			c++;
		}
		else
			mp.insert({getDigitSum(a[i])%3,a[i]});
	}
	int count=c/2;
	multimap<int,int>::iterator ip;
	for(multimap<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		int s=(3-(it->first))%3;
		int valSum=it->first;
		int val=it->second;
		mp.erase(it);
		if(mp.find(s)!=mp.end()){
			ip=mp.find(s);
			mp.erase(ip);
			count++;
		}
		else{
			mp.insert({valSum,val});
		}
	}

	cout<<count;
	return 0;
}


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

int getDigitSum(int n){
	int sum=0;
	while(n!=0){
		sum+=n%10;
		n/=10;
	}
return sum;
}

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n];
	int c=0;
	int count[3]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		count[getDigitSum(a[i])%3]++;
	}
	c+=count[0]/2;
	c+=min(count[1],count[2]);
	cout<<c;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define SI1(v)  scanf("%d",&v)					    // int 1
#define SI2(v1,v2)  scanf("%d%d",&v1,&v2)	     	// int 2
#define SI3(v1,v2,v3)  scanf("%d%d%d",&v1,&v2,&v3)  // int 3
#define SLL1(v)  scanf("%lld",&v)					// long long 1
#define SLL2(v1,v2)  scanf("%lld%lld",&v1,&v2)      // long long 2
#define PI1(v)  printf("%d\n",v)					    // int 1
#define PI2(v1,v2)  printf("%d %d\n",v1,v2)	     	// int 2
#define PLL1(v)  printf("%lld\n",v)					// long long 1
#define Line    printf("\n");
typedef long long ll;
const int N=100005;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif
   // three sets set for remainder 1, 2 ,0
   //  n%3   == sum of digit(n) % 3
  // take pair from set1 set2 min()
  // set 3 take the half

    int n,x,a[3]= {};
    SI1(n);
    for(int i=0; i<n; i++){
        SI1(x);
    string tmp=to_string(x);
    int val=0;
    for(int j=0;j<tmp.size();j++)
      val+=tmp[j]-'0';
        a[val%3]++;
    }
    int res=min(a[1],a[2])+a[0]/2;
    PI1(res);
}
/*
10
10101
10 10 1
10 1 01
1 010 1
1 01 01

*/


#include<bits/stdc++.h>
using namespace std;
#define SI1(v)  scanf("%d",&v)					    // int 1
#define SI2(v1,v2)  scanf("%d%d",&v1,&v2)	     	// int 2
#define SI3(v1,v2,v3)  scanf("%d%d%d",&v1,&v2,&v3)  // int 3
#define SLL1(v)  scanf("%lld",&v)					// long long 1
#define SLL2(v1,v2)  scanf("%lld%lld",&v1,&v2)      // long long 2
#define PI1(v)  printf("%d\n",v)					    // int 1
#define PI2(v1,v2)  printf("%d %d\n",v1,v2)	     	// int 2
#define PLL1(v)  printf("%lld\n",v)					// long long 1
#define Line    printf("\n");
typedef long long ll;
const int N=100005;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif
   // three sets set for remainder 1, 2 ,0
   //  n%3   == sum of digit(n) % 3

    int n,a[10005]= {};
    set<int>R1,R2,R0;
    SI1(n);
    for(int i=0; i<n; i++){
        SI1(a[i]);
    string tmp=to_string(a[i]);
    int val=0;
    for(int j=0;j<tmp.size();j++)
      val+=tmp[j]-'0';

    if(val%3==0)R0.insert(a[i]);
    else if(val%3==1)R1.insert(a[i]);
    else if(val%3==2)R2.insert(a[i]);
    }
    int res=min(R1.size(),R2.size())+R0.size()/2;
    PI1(res);
}
/*
10
10101
10 10 1
10 1 01
1 010 1
1 01 01

*/


#include<bits/stdc++.h>
using namespace std;
#define SI1(v)  scanf("%d",&v)					    // int 1
#define SI2(v1,v2)  scanf("%d%d",&v1,&v2)	     	// int 2
#define SI3(v1,v2,v3)  scanf("%d%d%d",&v1,&v2,&v3)  // int 3
#define SLL1(v)  scanf("%lld",&v)					// long long 1
#define SLL2(v1,v2)  scanf("%lld%lld",&v1,&v2)      // long long 2
#define PI1(v)  printf("%d\n",v)					    // int 1
#define PI2(v1,v2)  printf("%d %d\n",v1,v2)	     	// int 2
#define PLL1(v)  printf("%lld\n",v)					// long long 1
#define Line    printf("\n");
typedef long long ll;
const int N=100005;

int main()
{

#ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
//    freopen("output.txt","w",stdout);
#endif
    int n,a[10005]= {};
    set<int>R1,R2,R0;
    SI1(n);
    for(int i=0; i<n; i++){
        SI1(a[i]);
    if(a[i]%3==0)R0.insert(a[i]);
    else if(a[i]%3==1)R1.insert(a[i]);
    else if(a[i]%3==2)R2.insert(a[i]);
    }
    int res=min(R1.size(),R2.size())+R0.size()/2;
    PI1(res);
}
/*
10
10101
10 10 1
10 1 01
1 010 1
1 01 01

*/