#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), s(n + 1);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) s[i + 1] = s[i] + abs(a[i]);

  ll minus = INFL, minus_cnt = 0;
  rep(i, 0, n) {
    if (a[i] == 0) {
      minus = INFL;
      minus_cnt = 0;
    } else {
      minus = min(minus, abs(a[i]));
      if (a[i] < 0) ++minus_cnt;
    }
  }
  cout << s[n] - (minus_cnt % 2 == 0 ? 0 : minus * 2) << endl;
}
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.20f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define cotu cout
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll A[300100];
    rep(i,0,n) cin >> A[i];
    int cnt[65];
    Fill(cnt, 0);
    rep(i,0,n){
        ll tmp = A[i];
        int j = 0;
        while(tmp > 0){
            cnt[j] += (tmp % 2);
            tmp /= 2;
            j++;
        }
    }

    ll ans = 0;
    rep(i,0,60){
        ll tmp = modpow(2,i,MOD);
        ans += (tmp * (n-cnt[i]) % MOD) * cnt[i] % MOD;
    }

    ans %= MOD;
    cout << ans << endl;
    return 0;
}
