#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
int add (int x, int y) {return x + y >= mod ? x + y - mod : x + y;}
int mul (int x, int y) {return 1LL * x * y % mod;}
int sub (int x, int y) {return x - y < 0 ? x - y + mod : x - y;}

int n, a[maxn];
int f[maxn][2], g[maxn][2];

int main ()
{
    scanf ("%d", &n);
    for (int i = 1; i <= n; i++) scanf ("%d", a + i);
    f[1][0] = a[1];
    g[1][0] = 1;
    for (int i = 2; i <= n; i++)
    {
        g[i][0] = add (g[i - 1][1], g[i - 1][0]);
        g[i][1] = g[i - 1][0];
        f[i][0] = add (f[i - 1][1], f[i - 1][0]);
        f[i][0] = add (f[i][0], mul (g[i][0], a[i]));
        f[i][1] = sub (f[i - 1][0], mul (g[i][1], a[i]));

    }
    int ans = add (f[n][0], f[n][1]);
    printf ("%d\n", ans);
}

#include <bits/stdc++.h>
const int N = 200005;
int n, a[N * 2], b[N * 2], ok[N * 2], st[N], top = 0;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n * 2; i++)
		scanf("%d", &a[i]), b[i] = i;
	std::sort(b + 1, b + n * 2 + 1, [](int x, int y) { return a[x] < a[y]; });
	for (int i = 1; i <= n; i++) ok[b[i]] = 1;
	for (int i = 1; i <= n * 2; i++) {
		char c;
		if (!top) st[++top] = i, c = '(';
		else if (ok[st[top]] ^ ok[i]) top--, c = ')';
		else st[++top] = i, c = '(';
		putchar(c);
	}
	return 0;
}