#include #include using namespace std; int main(void){ int n; cin >> n; vector a(n); long long sum = 0; for (int i = 0; i < n; i++) cin >> a[i]; int bwor; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { if (j==i) { bwor = a[i] | a[j]; } else bwor = bwor | a[j]; sum += bwor; } } cout << sum << endl; }