#include using namespace std; using ll = long long; #define rep(i,a,b) for(int i =a; i <(b); ++i) const int BIT = 62; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int n; cin >> n; vector a(n); for (auto &x : a) cin >> x; vector cnt(BIT + 1, 0); for (int i = 0; i < n; i++) { for (int j = 0; a[i] > 0; j++) { if (a[i] % 2 == 1) cnt[j] += 1; a[i] /= 2; } } ll ans = 0; for (int i = 0; i <= BIT; i++) { if (cnt[i] != 0) { ans |= (1ll << i); } if (cnt[i] < 2) continue; cnt[i + 1] += cnt[i] / 2; } cout << ans << "\n"; return 0; }