#include <bits/stdc++.h>
using namespace std;
int main() {
    long long n,sum=0,res=0;
    cin>>n;
    long long a[n];
    long long  mod= 998244353;
    for(long long i=0;i<n;i++){
    cin>>a[i];
    }
    sort(a,a+n,greater<long long>());
    for(long long i=0;i<n;i++)
    {
        res+=(a[i]*a[i]);
        res+=(a[i]*sum);
        res=res%mod;
        sum=sum*2;
        sum+=a[i];
        sum=sum%mod;
    }
    cout<<res;
    
}
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = INT_MAX;
    for (int i = 0; i < (1<<(n-1)); i++)
    {
        int in, out;
        in = out = 0;
        for (int j = 0; j < n; j++)
        {
            in |= a[j];
            if (i&1<<j)
            {
                out ^= in;
                in = 0;
            }
        }
        out ^= in;
        ans = min(ans, out);
    }
    cout << ans << endl;
}
