#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
inline long long int add(long long int a, long long int b) {
  a += b;
  if (a >= 100000000) a -= 100000000;
  return a;
}
inline long long int sub(long long int a, long long int b) {
  a -= b;
  if (a < 0) a += 100000000;
  return a;
}
inline long long int mul(long long int a, long long int b) {
  return (long long int)((long long)a * b % 100000000);
}
inline long long int poww(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b /= 2;
  }
  return res;
}
inline long long int inv(long long int a) { return poww(a, 100000000 - 2); }
long long int gcd(long long int a, long long int b, long long int &x,
                  long long int &y) {
  if (a == 0) {
    x = 0, y = 1;
    return b;
  }
  long long int x1, y1;
  long long int d = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return d;
}
inline std::vector<std::vector<long long int> > matmul(
    std::vector<std::vector<long long int> > A,
    std::vector<std::vector<long long int> > B) {
  long long int p = A.size(), q = A[0].size();
  long long int r = B.size(), s = B[0].size();
  assert(q == r);
  std::vector<std::vector<long long int> > C(
      p, std::vector<long long int>(s, 0LL));
  for (long long ll i = 0; i <= p - 1; i++) {
    for (long long ll j = 0; j <= s - 1; j++) {
      for (long long ll k = 0; k <= q - 1; k++) {
        C[i][j] = add(C[i][j], mul(A[i][k], B[k][j]));
      }
    }
  }
  return C;
}
inline std::vector<std::vector<long long int> > matpow(
    std::vector<std::vector<long long int> > A, long long int n) {
  long long int p = A.size(), q = A[0].size();
  assert(p == q);
  std::vector<std::vector<long long int> > res(
      p, std::vector<long long int>(p, 0));
  for (long long ll i = 0; i <= p - 1; i++) res[i][i] = 1;
  while (n) {
    if (n & 1) res = matmul(res, A);
    A = matmul(A, A);
    n >>= 1;
  }
  return res;
}
struct factorial {
  long long int N;
  long long int *fac;
  long long int *ifac;
  long long int MOD;
  factorial(long long int n, long long int m = 1000000007) {
    N = n;
    MOD = m;
    fac = new long long int[1 + N];
    ifac = new long long int[1 + N];
    pre_calc();
  }
  long long int add(long long int a, long long int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
  }
  long long int subtract(long long int a, long long int b) {
    a -= b;
    if (a < 0) a += MOD;
    return a;
  }
  long long int multiply(long long int a, long long int b) {
    return (long long int)((long long)a * b % MOD);
  }
  long long int binpow(long long int a, long long int b) {
    long long int res = 1;
    while (b > 0) {
      if (b & 1) res = multiply(res, a);
      a = multiply(a, a);
      b /= 2;
    }
    return res;
  }
  long long int inverse(long long int a) { return binpow(a, MOD - 2); }
  void pre_calc() {
    fac[0] = ifac[0] = 1;
    for (long long int i = 1; i <= N; i++) {
      fac[i] = multiply(fac[i - 1], i);
      ifac[i] = multiply(ifac[i - 1], inverse(i));
    }
  }
  long long int ncr(long long int n, long long int r) {
    return multiply(fac[n], multiply(ifac[r], ifac[n - r]));
  }
  long long int derangement(long long int n) {
    if (n == 1) return 0;
    long long int ans = 0;
    for (long long int i = 2; i <= n; i++) {
      long long int sign = (i % 2) ? -1 : 1;
      ans = add(ans, multiply(sign, fac[n] / fac[i]));
    }
    return ans;
  }
};
std::vector<long long int> factors_n(long long int n) {
  std::vector<long long int> fac;
  for (long long int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      fac.push_back(i);
      if (i * i != n) {
        fac.push_back(n / i);
      }
    }
  }
  return fac;
}
struct fenwick_tree {
  long long int *bit;
  long long int n;
  fenwick_tree() {
    this->n = 100005;
    this->bit = new long long int[100005 + 1];
  }
  fenwick_tree(long long int n) {
    this->n = n;
    this->bit = new long long int[n + 1];
  }
  void add(long long int i, long long int v) {
    for (; i <= this->n; i += i & -i) this->bit[i] += v;
  }
  long long int get(long long int i) {
    long long int s = 0;
    for (; i; i -= i & -i) {
      s += this->bit[i];
    }
    return s;
  }
};
long long int no_of_ones(long long int n) { return __builtin_popcount(n); }
long long int setmask(long long int mask, long long int i) {
  return mask | (1 << i);
}
long long int unsetmask(long long int mask, long long int i) {
  return (mask & !(1 << i));
}
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
const long long int N = 1e5 + 5;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  std::vector<long long int> a(n);
  for (long long ll i = 0; i <= n - 1; i++) cin >> a[i];
  long long int b[62];
  memset(b, 0, sizeof(b));
  for (long long int x : a) {
    for (long long ll j = 0; j <= 62 - 1; j++) {
      if ((x & (1ll << j)) != 0) {
        b[j] += 1;
      }
    }
  }
  long long int ans = 0;
  for (long long ll i = 0; i <= 62 - 1; i++) {
    ans = add(ans, mul(mul(b[i], (n - b[i])), poww(2ll, i)));
  }
  cout << ans << '\n';
}
