#define    ll                long long
#define    dn                double
#define    mp                make_pair
#define    pb                push_back
#define    se                second
#define    fi                first
#define    mod               1000000007
#define    sob(v)            v.begin(),v.end()
#define    sobr(v)           v.rbegin(),v.rend()
#define    same(v)           v.erase(unique(v.begin(),v.end()),v.end())
#define    fr(i,a,b)         for(int i=a;i<=b;++i)
#define    frr(i,a,b)        for(int i=a;i>=b;--i)
#define    pi                acos(-1.00)
#define    inf               1e9
#define    EPS               1e-9
#define    sf(n)             scanf("%d",&n)
#define    sfl(n)            scanf("%lld",&n)
#define    check(n)          cout<<n<<"**CHECK"<<endl
#define    ffix(x)           cout<<fixed<<setprecision(x)
#define    fast              ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define    ones(mask)        __builtin_popcount(mask)   // count set bit
#define    onesLL(mask)      __builtin_popcountll(mask) // for long long
#define    lzeros(mask)      __builtin_clz(mask)        // no of leading zeros
#define    tzeros(mask)      __builtin_ctz(mask)        // no of trailing zeros


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

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<int,vi> pp;
typedef vector<pii> vpii;
typedef pair<pair<int,int>,int> pain;

int dr[8]= {-1,0,+1,0,-1,-1,+1,+1};
int dc[8]= {0,+1,0,-1,-1,+1,-1,+1};

int kx[8]= {-1,+1,+1,-1,+2,+2,-2,-2};
int ky[8]= {+2,+2,-2,-2,-1,+1,+1,-1};

const int N=100005;

int main()
{
    int n;
    cin>>n;
    ll a[n+1],b[n+1],pref[n+1];
    memset(pref,0,sizeof pref);
    memset(b,0,sizeof b);
    fr(i,1,n)
    {
        cin>>a[i];
        pref[i]=pref[i-1]+a[i];
    }
    fr(i,1,n)
    {
        b[i]=pref[i]+b[i-1];
    }
    ll mx=0;
    fr(i,1,n)
    {
        mx=max(mx,a[i]);
        ll ans=mx*i*1LL+b[i];
        cout<<ans<<endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s[105];
ll a[25];
int f[25];
int n;
vector<int>v;
void make(int x)
{
    for(int i=n;i>1;i--)
    {
        f[i]=x%2;
        x=x>>1;
    }
}
int main()
{

     ios::sync_with_stdio(false);

     cin>>n;
     for(int i=1;i<=n;i++)
     {
         cin>>a[i];
     }
     ll pre=0;
     ll ans=1e18;
     int nm=pow(2,n-1);
     for(int cnt=0;cnt<=nm-1;cnt++)
     {
         make(cnt);
         f[1]=1;
         pre=0;
       //  cout<<cnt<<"cnt"<<endl;
         v.clear();
         for(int i=1;i<=n;i++)
         {
             if(f[i]==1)
             {
                 pre=pre|a[i];
             }
             else
             {
                 v.push_back(pre);
                 pre=a[i];
             }
         //    cout<<pre<<endl;
         }
         v.push_back(pre);
         ll x=v[0];
         for(int i=1;i<v.size();i++)
         {
             x=x^v[i];
         }
         ans=min(ans,x);
       //  cout<<x<<endl;

     }
     cout<<ans<<endl;

}
/*3
1 5 7
0cnt
1
5
7
3
1cnt
1
5
7
5
2cnt
1
5
7
7
3cnt
1
5
7
0
0
*/
