cin >> n; for (int i = 1; i <= n; ++i) cin >> a[i]; base[0] = 1; for (int i = 1; i < 60; ++i) base[i] = base[i - 1] * 2ll % p; for (int i = 1; i <= n; ++i) for (int s = 0; s < 30; ++s) for (int t = 0; t < 30; ++t) cnt[s][t][a[i] >> s & 1][a[i] >> t & 1]++; int ans = 0; for (int i = 0; i < 30; ++i) for (int j = 0; j < 30; ++j) for (int s = 0; s < 2; ++s) for (int t = 0; t < 2; ++t) ans = (ans + 1ll * base[i + j] * cnt[i][j][s][t] % p * cnt[i][j][s ^ 1][t ^ 1]) % p; cout << ans << "\n"; }