#include <iostream>
using namespace std;
char m[12][13];
void dfs(int x, int y)
{
	int i, j, nx, ny;
	m[y][x] = '0';
	for (i = 1; i >= -1; i--)
	{
		if (i == 1 || i == -1)
		{
			nx = x;
			ny = y + i;
			if (0 <= nx && nx < 12 && 0 <= ny && ny < 12 && m[ny][nx] == '1') dfs(nx, ny);
		}
		else
		{
			for (j = 1; j >= -1; j--)
			{
				nx = x + j;
				ny = y + i;
				if (0 <= nx && nx < 12 && 0 <= ny && ny < 12 && m[ny][nx] == '1') dfs(nx, ny);
			}
		}
	}
	return;
}
int main()
{
	int i, j, n;
	while (1)
	{
		for (i = 0; i < 12; i++)
		{
			cin >> m[i];
			if (cin.eof()) return 0;
		}
		n = 0;
		for (i = 0; i < 12; i++)
		{
			for (j = 0; j < 12; j++)
			{
				if (m[i][j] == '1')
				{
					n++;
					dfs(j, i);
				}
			}
		}
		cout << n << endl;
	}
}
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF -1000000000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

ll n,ara[200005];
vector< vector<ll> > dp(200005, vector<ll> (5,INF));



ll f(ll i, ll j){

  

    if(i>n) return 0;

    if(dp[i][j]!=INF) return dp[i][j];

    if(j==0){ 
        if(i>=n) return 0;  
        dp[i][j] = ara[i] + max(max(f(i+2,0),f(i+3,3)),f(i+4,1));
        return dp[i][j];
    }
    if(j==2) return dp[i][j] = ara[i] + max(f(i+2,2),f(i+3,1)); 
    if(j==3) return dp[i][j] = ara[i] + max(f(i+2,3),f(i+3,1));
    else     return  dp[i][j] = ara[i] + f(i+2,1);
    


}







int main(){
	
    ll i;
    cin>>n;
    for(i=1;i<=n;i++) cin>>ara[i];
    if(n%2==1){  
    cout<<max(max(f(1,0),f(2,2)),f(3,1))<<endl;
    }
    else{
        cout<<max(f(1,2),f(2,1))<<endl;
    }

	return 0;
}