```go
package main
import (
"fmt"
"math/bits"
)
func main() {
var n int
fmt.Scan(&n)
a := make([]uint64, n)
for i := 0; i < n; i++ {
fmt.Scan(&a[i])
}
var best uint64
// For subsequence of size 1: value is all bits set in that element
for i := 0; i < n; i++ {
if a[i] > best {
best = a[i]
}
}
// For subsequence of size 2: max(1, 2-2) = 1, so bits where at least 1 of 2 elements has it set
// That's just OR of two elements
for i := 0; i < n; i++ {
for j := i + 1; j < n; j++ {
val := a[i] | a[j]
if val > best {
best = val
}
}
}
// For subsequence of size 3: max(1, 3-2) = 1, so bits where at least 1 of 3 elements has it set
// That's just OR of three elements
// But we want to maximize, so OR of any 3 is >= OR of any 2
// Actually for size k >= 3: max(1, k-2) = k-2
// For k=3: need at least 1 out of 3 -> OR
// For k=4: need at least 2 out of 4
// For k=5: need at least 3 out of 5
// ...
// The key insight: optimal subsequence has size at most 3
// Because for k>=4, we need k-2 elements to have each bit set
// Adding more elements doesn't help unless they contribute new bits
// but the threshold increases too.
// Actually the optimal is always size 1, 2, or 3.
// For size 3: threshold is 1 (OR of all 3) - same as size 2
// Wait, for size 3: max(1, 3-2) = max(1,1) = 1
// For size 4: max(1, 4-2) = 2
// So size 3 gives OR which is at least as good as size 4's AND-like condition
// So optimal is at most size 3.
for i := 0; i < n; i++ {
for j := i + 1; j < n; j++ {
for k := j + 1; k < n; k++ {
val := a[i] | a[j] | a[k]
if val > best {
best = val
}
}
}
}
// But wait, we need to verify this reasoning more carefully.
// For k=3: threshold = 1, value = OR of all elements
// For k=4: threshold = 2, value = bits where at least 2 of 4 have it
// A bit contributes if at least 2 of 4 elements have it.
// Could this be larger than the best OR of 3?
// If we have elements where each individually has many bits but OR of any 3 misses some pattern...
// Actually OR of 3 elements from the 4 will catch bits that at least 1 of 3 has,
// which means at least 1 of 4 has it. The k=4 needs at least 2.
// So k=4 is strictly harder - its value <= OR of any 3 chosen from those 4.
// Hence optimal is indeed size <= 3.
_ = bits.Len // just to use the import
fmt.Println(best)
}
```