#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.hpp"
#else
#define debug(...) 8
#endif
typedef long long ll;
#define f(i, x, n) for (ll i = x; i < n; i++)
#define rf(i, x, n) for (ll i = x; i >= n; i--)
#define fr(x,ds) for(auto &x : ds)
#define pb push_back
#define all(x) (x).begin(), (x).end()
const ll mod = 998244353;
const ll inf = 1e18;
const ll N = 1e5+5;
void solve(){
ll n;
cin>>n;
vector<ll> a(n);
f(i,0,n) cin>>a[i];
ll ans=0;
f(i,0,30) {
bool ev=0;
ll even=-1,odd=0;
ll evencnt=1,oddcnt=0;
ll sum=0;
f(j,0,n) {
if((1ll<<i)&a[j]) {
ev^=1;
}
if(!ev) {
even+=j;
evencnt++;
}
else {
odd+=j;
oddcnt++;
}
if(ev) {
sum+=j*evencnt-even;
}
else {
sum+=j*oddcnt-odd;
}
}
ll tmp=(sum%mod)*((1ll<<i)%mod)%mod;
ans=(ans+tmp)%mod;
}
cout<<ans<<'\n';
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t = 1;
// cin >> t;
for (ll T = 1; T <= t; T++) {
// cout << "Case #" << T << ": ";
solve();
}
return 0;
}
125B - Simple XML | 567B - Berland National Library |
431B - Shower Line | 282C - XOR and OR |
1582B - Luntik and Subsequences | 609A - Флеш-карты |
1207A - There Are Two Types Of Burgers | 371C - Hamburgers |
343B - Alternating Current | 758B - Blown Garland |
1681B - Card Trick | 1592A - Gamer Hemose |
493D - Vasya and Chess | 1485A - Add and Divide |
337B - Routine Problem | 1392D - Omkar and Bed Wars |
76E - Points | 762C - Two strings |
802M - April Fools' Problem (easy) | 577B - Modulo Sum |
1555B - Two Tables | 1686A - Everything Everywhere All But One |
1469B - Red and Blue | 1257B - Magic Stick |
18C - Stripe | 1203B - Equal Rectangles |
1536A - Omkar and Bad Story | 1509A - Average Height |
1506C - Double-ended Strings | 340A - The Wall |