Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class pepsicola {
- private static InputReader in;
- private static PrintWriter out;
- public static int mod = 1000000007;
- public static long exp(long b, long e) {
- long r = 1;
- while (e > 0) {
- if (e % 2 == 1) r = r * b % mod;
- b = b * b % mod;
- e >>= 1;
- }
- return r;
- }
- public static int MAXL = 17;
- public static void main(String[] args) throws IOException {
- in = new InputReader(System.in);
- out = new PrintWriter(System.out, true);
- int n = in.nextInt();
- int[] freq = new int[1 << MAXL];
- for (int i = 0; i < n; i++)
- freq[in.nextInt()]++;
- for (int i = 0; i < MAXL; i++) {
- for (int j = 0; j < freq.length; j++) {
- if ((j & (1 << i)) != 0) {
- freq[j] += freq[j ^ (1 << i)];
- }
- }
- }
- long[] ans = new long[1 << MAXL];
- for (int i = 0; i < freq.length; i++)
- ans[i] = exp(2, freq[i]);
- for (int i = 0; i < MAXL; i++) {
- for (int j = 0; j < freq.length; j++) {
- if ((j & (1 << i)) != 0) {
- ans[j] = (ans[j] + mod - ans[j ^ (1 << i)]) % mod;
- }
- }
- }
- long sum = 0;
- for (int i = 0; i < ans.length; i++) {
- sum = (sum + ans[i] * exp(i, 3)) % mod;
- }
- out.println(sum);
- out.close();
- System.exit(0);
- }
- static class InputReader {
- public BufferedReader reader;
- public StringTokenizer tokenizer;
- public InputReader(InputStream stream) {
- reader = new BufferedReader(new InputStreamReader(stream), 32768);
- tokenizer = null;
- }
- public String next() {
- while (tokenizer == null || !tokenizer.hasMoreTokens()) {
- try {
- tokenizer = new StringTokenizer(reader.readLine());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- return tokenizer.nextToken();
- }
- public int nextInt() {
- return Integer.parseInt(next());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement