#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---

const int N = 202020, inf = 1e9;

struct Seg {
#define ls rt << 1
#define rs ls | 1
	static const int N = ::N << 2;
	ll sum[N];
	int mi[N][2], cnt[N];
	void up(int rt) {
		sum[rt] = sum[ls] + sum[rs];
		rep(i, 0, 2) mi[rt][i] = min(mi[ls][i], mi[rs][i]);
		cnt[rt] = 0;
		rep(i, 0, 2) {
			if(mi[rt][0] == mi[ls | i][0]) cnt[rt] += cnt[ls | i];
			else mi[rt][1] = min(mi[rt][1], mi[ls | i][0]);
		}
	}
	void build(int l, int r, int rt) {
		if(l == r) {
			sum[rt] = mi[rt][0] = l;
			sum[rt] = 0;
			mi[rt][1] = inf;
			cnt[rt] = 1;
			return ;
		}
		int mid = l + r >> 1;
		build(l, mid, ls);
		build(mid + 1, r, rs);
		up(rt);
	}
	void gao(int rt, int c) {
		if(c <= mi[rt][0]) return ;
		sum[rt] += 1ll * cnt[rt] * (c - mi[rt][0]);
		mi[rt][0] = c;
	}
	void down(int rt) {
		gao(ls, mi[rt][0]);
		gao(rs, mi[rt][0]);
	}
	void upd(int L, int R, int c, int l, int r, int rt) {
		if(L > R) return ;
		if(L <= l && r <= R && c < mi[rt][1]) {
			gao(rt, c);
			return ;
		}
		int mid = l + r >> 1;
		down(rt);
		if(L <= mid) upd(L, R, c, l, mid, ls);
		if(R > mid) upd(L, R, c, mid + 1, r, rs);
		up(rt);
	}
}seg;

int n;
int a[N];
ll h[N];
vi v[N];

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n;
	rep(i, 1, n + 1) {
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; ++j) if(a[i] % j == 0) {
			v[j].pb(i);
			if(a[i] / j != j) v[a[i] / j].pb(i);
		}
	}
	seg.build(1, n, 1);
	for(int i = n; ~i; --i) {
		h[i] = 1ll * n * n + n - seg.sum[1];
		if(sz(v[i]) >= 2) {
			seg.upd(1, v[i][0], v[i][sz(v[i]) - 2], 1, n, 1);
			seg.upd(v[i][0] + 1, v[i][1], v[i][sz(v[i]) - 1], 1, n, 1);
			seg.upd(v[i][1] + 1, n, n + 1, 1, n, 1);
		}
	}
	ll ans = 0;
	rep(i, 1, n + 1) ans += i * (h[i] - h[i - 1]);
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---

const int N = 202020, inf = 1e9;

struct Seg {
#define ls rt << 1
#define rs ls | 1
	static const int N = ::N << 2;
	ll sum[N];
	int mi[N][2], cnt[N];
	void up(int rt) {
		sum[rt] = sum[ls] + sum[rs];
		rep(i, 0, 2) mi[rt][i] = min(mi[ls][i], mi[rs][i]);
		cnt[rt] = 0;
		rep(i, 0, 2) {
			if(mi[rt][0] == mi[ls | i][0]) cnt[rt] += cnt[ls | i];
			else mi[rt][1] = min(mi[rt][1], mi[ls | i][0]);
		}
	}
	void build(int l, int r, int rt) {
		if(l == r) {
			sum[rt] = mi[rt][0] = l;
			mi[rt][1] = inf;
			cnt[rt] = 1;
			return ;
		}
		int mid = l + r >> 1;
		build(l, mid, ls);
		build(mid + 1, r, rs);
		up(rt);
	}
	void gao(int rt, int c) {
		if(c <= mi[rt][0]) return ;
		sum[rt] += 1ll * cnt[rt] * (c - mi[rt][0]);
		mi[rt][0] = c;
	}
	void down(int rt) {
		gao(ls, mi[rt][0]);
		gao(rs, mi[rt][0]);
	}
	void upd(int L, int R, int c, int l, int r, int rt) {
		if(L > R) return ;
		if(L <= l && r <= R && c < mi[rt][1]) {
			gao(rt, c);
			return ;
		}
		int mid = l + r >> 1;
		down(rt);
		if(L <= mid) upd(L, R, c, l, mid, ls);
		if(R > mid) upd(L, R, c, mid + 1, r, rs);
		up(rt);
	}
}seg;

int n;
int a[N];
ll h[N];
vi v[N];

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n;
	rep(i, 1, n + 1) {
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; ++j) if(a[i] % j == 0) {
			v[j].pb(i);
			if(a[i] / j != j) v[a[i] / j].pb(i);
		}
	}
	seg.build(1, n, 1);
	for(int i = N - 1; ~i; --i) {
		h[i] = 1ll * n * n + n - seg.sum[1];
		if(sz(v[i]) >= 2) {
			seg.upd(1, v[i][0], v[i][sz(v[i]) - 2], 1, n, 1);
			seg.upd(v[i][0] + 1, v[i][1], v[i][sz(v[i]) - 1], 1, n, 1);
			seg.upd(v[i][1] + 1, n, n + 1, 1, n, 1);
		}
	}
	ll ans = 0;
	rep(i, 1, n + 1) ans += i * (h[i] - h[i - 1]);
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---

const int N = 202020, inf = 1e9;

struct Seg {
#define ls rt << 1
#define rs ls | 1
	static const int N = ::N << 2;
	ll sum[N];
	int mi[N][2], cnt[N];
	void up(int rt) {
		sum[rt] = sum[ls] + sum[rs];
		rep(i, 0, 2) mi[rt][i] = min(mi[ls][i], mi[rs][i]);
		cnt[rt] = 0;
		rep(i, 0, 2) {
			if(mi[rt][0] == mi[ls | i][0]) cnt[rt] += cnt[ls | i];
			else mi[rt][1] = min(mi[rt][1], mi[ls | i][0]);
		}
	}
	void build(int l, int r, int rt) {
		if(l == r) {
			sum[rt] = mi[rt][0] = l;
			mi[rt][1] = inf;
			cnt[rt] = 1;
			return ;
		}
		int mid = l + r >> 1;
		build(l, mid, ls);
		build(mid + 1, r, rs);
		up(rt);
	}
	void gao(int rt, int c) {
		if(c <= mi[rt][0]) return ;
		sum[rt] += 1ll * cnt[rt] * (c - mi[rt][0]);
		mi[rt][0] = c;
	}
	void down(int rt) {
		gao(ls, mi[rt][0]);
		gao(rs, mi[rt][0]);
	}
	void upd(int L, int R, int c, int l, int r, int rt) {
		if(L > R) return ;
		if(L <= l && r <= R && c < mi[rt][1]) {
			gao(rt, c);
			return ;
		}
		int mid = l + r >> 1;
		down(rt);
		if(L <= mid) upd(L, R, c, l, mid, ls);
		if(R > mid) upd(L, R, c, mid + 1, r, rs);
		up(rt);
	}
}seg;

int n;
int a[N];
ll h[N];
vi v[N];

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n;
	rep(i, 1, n + 1) {
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; ++j) if(a[i] % j == 0) {
			v[j].pb(i);
			if(a[i] / j != j) v[a[i] / j].pb(i);
		}
	}
	seg.build(1, n, 1);
	for(int i = n; ~i; --i) {
		h[i] = 1ll * n * n + n - seg.sum[1];
		if(sz(v[i]) >= 2) {
			seg.upd(1, v[i][0], v[i][sz(v[i]) - 2], 1, n, 1);
			seg.upd(v[i][0] + 1, v[i][1], v[i][sz(v[i]) - 1], 1, n, 1);
			seg.upd(v[i][1] + 1, n, n + 1, 1, n, 1);
		}
	}
	ll ans = 0;
	rep(i, 1, n + 1) ans += i * (h[i] - h[i - 1]);
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---

const int N = 202020, inf = 1e9;

struct Seg {
#define ls rt << 1
#define rs ls | 1
	static const int N = ::N << 2;
	ll sum[N];
	int mi[N][2], cnt[N];
	void up(int rt) {
		sum[rt] = sum[ls] + sum[rs];
		rep(i, 0, 2) mi[rt][i] = min(mi[ls][i], mi[rs][i]);
		cnt[rt] = 0;
		rep(i, 0, 2) {
			if(mi[rt][0] == mi[ls | i][0]) cnt[rt] += cnt[ls | i];
			else mi[rt][1] = min(mi[rt][1], mi[ls | i][0]);
		}
	}
	void build(int l, int r, int rt) {
		if(l == r) {
			sum[rt] = mi[rt][0] = l;
			mi[rt][1] = inf;
			cnt[rt] = 1;
			return ;
		}
		int mid = l + r >> 1;
		build(l, mid, ls);
		build(mid + 1, r, rs);
		up(rt);
	}
	void gao(int rt, int c) {
		if(c <= mi[rt][0]) return ;
		sum[rt] += 1ll * cnt[rt] * (c - mi[rt][0]);
		mi[rt][0] = c;
	}
	void down(int rt) {
		gao(ls, mi[rt][0]);
		gao(rs, mi[rt][0]);
	}
	void upd(int L, int R, int c, int l, int r, int rt) {
		if(L > R) return ;
		if(L <= l && r <= R && c < mi[rt][1]) {
			gao(rt, c);
			return ;
		}
		int mid = l + r >> 1;
		down(rt);
		if(L <= mid) upd(L, R, c, l, mid, ls);
		if(R > mid) upd(L, R, c, mid + 1, r, rs);
		up(rt);
	}
}seg;

int n;
int a[N];
ll h[N];
vi v[N];

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n;
	rep(i, 1, n + 1) {
		cin >> a[i];
		for(int j = 1; j * j <= a[i]; ++j) if(a[i] % j == 0) {
			v[j].pb(i);
			if(a[i] / j != j) v[a[i] / j].pb(i);
		}
	}
	seg.build(1, n, 1);
	for(int i = N - 1; ~i; --i) {
		h[i] = 1ll * n * n + n - seg.sum[1];
		if(sz(v[i]) >= 2) {
			seg.upd(1, v[i][0], v[i][sz(v[i]) - 2], 1, n, 1);
			seg.upd(v[i][0] + 1, v[i][1], v[i][sz(v[i]) - 1], 1, n, 1);
			seg.upd(v[i][1] + 1, n, n + 1, 1, n, 1);
		}
	}
	ll ans = 0;
	rep(i, 1, N) ans += i * (h[i] - h[i - 1]);
	cout << ans << endl;
	return 0;
}


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

const int NX = 2e5 + 10;
const int VALUEX = 2e5 + 10;
const int NO_DATA = -1;
struct segment {
  long sum, lazy, maxf, minf;
  segment () { sum = 0; lazy = NO_DATA; maxf = 0, minf = 0; }
} IT[4 * NX];

int N;
int a[NX];
long H[VALUEX];
vector <int> v[NX];
vector <int> primes;
int not_prime[VALUEX];
int where[VALUEX];

void Sieve () {
  not_prime[1] = 1;
  for (int i = 2; i*i < VALUEX; i++) {
    if(not not_prime[i]){
      for (int k = i*i; k < VALUEX; k += i) {
        not_prime[k] = 1;
      }
    }
  }
  for (int i = 2; i < VALUEX; i++) {
    if (not not_prime[i]) primes.emplace_back(i);
  }
}

void propagate (int node, int LL, int RR) {
  if (IT[node].lazy == NO_DATA) return;
  if (LL != RR) {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = node * 2 + 1;
    IT[foo].sum = (MM - LL + 1) * IT[node].lazy;
    IT[bar].sum = (RR - MM) * IT[node].lazy;
    IT[foo].lazy = IT[node].lazy;
    IT[bar].lazy = IT[node].lazy;
    IT[foo].maxf = IT[bar].maxf = IT[foo].minf = IT[bar].maxf = IT[node].lazy;
    IT[node].lazy = NO_DATA;
  }
}

void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node].sum = IT[node].maxf = IT[node].minf = LL;

  } else {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = node * 2 + 1;
    build (foo, LL, MM);
    build (bar, MM + 1, RR);
    IT[node].sum = IT[foo].sum + IT[bar].sum;
    IT[node].maxf = max (IT[foo].maxf, IT[bar].minf);
    IT[node].minf = min (IT[foo].minf, IT[bar].minf);
  }
}

void assign (int x, int y, int value, int node = 1, int LL = 1, int RR = N) {
  propagate(node, LL, RR);
  if (x > RR || y < LL || IT[node].minf >= value) return;
  if (x <= LL && RR <= y && IT[node].maxf <= value) {
    IT[node].sum = value * (RR - LL + 1);
    IT[node].maxf = IT[node].minf = value;
    IT[node].lazy = value;
  } else {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = foo + 1;
    assign (x, y, value, foo, LL, MM);
    assign (x, y, value, bar, MM + 1, RR);
    IT[node].sum = IT[foo].sum + IT[bar].sum;
    IT[node].maxf = max (IT[foo].maxf, IT[bar].maxf);
    IT[node].minf = min (IT[foo].minf, IT[bar].minf);
  }
}

void printff (int x, int node = 1, int LL = 1, int RR = N) {
  propagate (node , LL, RR);
  if (x > RR || x < LL) return;
  if (LL == RR) {
    printf("value of %d = %lld\n", LL, IT[node].sum);
  }
  else {
    int foo = node * 2;
    int bar = foo + 1;
    int MM = (LL + RR) / 2;
    printff (x, foo, LL, MM);
    printff (x, bar, MM + 1, RR);
  }
}

int main(){
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    where[a[i]] = i;
  }
  for (int i = 1; i < VALUEX; i++) {
    for (int k = i; k < VALUEX; k += i) {
      if (where[k] != 0) {
        v[i].emplace_back(where[k]);
      }
    }
    sort (v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= N; i++) assign (i, i, i);
  //for (int i = 1; i <= N; i++) printff (i);
  for (int i = VALUEX - 1; i >= 1; i--) {
    if (v[i].size() >= 2) {
      assign (v[i][1] + 1, N, N + 1);
      assign (v[i][0] + 1, v[i][1], v[i][v[i].size() - 1]);
      assign (1, v[i][0], v[i][v[i].size() - 2]);
    }
    H[i] = N * (N + 1) - IT[1].sum;
  }
  long res = 0;
  //for (int i = 1; i <= 10; i++) printf("%d\n", H[i]);
  for (int i = 1; i < VALUEX - 1; i++) {
    res += (H[i + 1] - H[i]) * i;
  }
  printf("%lld", res);
  return 0;
}


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

const int NX = 2e5 + 10;
const int VALUEX = 2e5 + 10;
const int NO_DATA = -1;
struct segment {
  long sum, lazy;
  segment () { sum = 0; lazy = NO_DATA; }
} IT[4 * NX];

int N;
int a[NX];
long H[VALUEX];
vector <int> v[NX];
vector <int> primes;
int not_prime[VALUEX];
int pos[VALUEX];

void Sieve () {
  not_prime[1] = 1;
  for (int i = 2; i*i < VALUEX; i++) {
    if(not not_prime[i]){
      for (int k = i*i; k < VALUEX; k += i) {
        not_prime[k] = 1;
      }
    }
  }
  for (int i = 2; i < VALUEX; i++) {
    if (not not_prime[i]) primes.emplace_back(i);
  }
}

void propagate (int node, int LL, int RR) {
  if (IT[node].lazy == NO_DATA) return;
  if (LL != RR) {
    int MM = (LL + RR) / 2;
    IT[node * 2].sum = (MM - LL + 1) * IT[node].lazy;
    IT[node * 2 + 1].sum = (RR - MM) * IT[node].lazy;
    IT[node * 2].lazy = IT[node].lazy;
    IT[node * 2 + 1].lazy = IT[node].lazy;
    IT[node].lazy = NO_DATA;
  }
}

void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node].sum = LL;
  } else {
    int MM = (LL + RR) / 2;
    build (node * 2, LL, MM);
    build (node * 2 + 1, MM + 1, RR);
    IT[node].sum = IT[node *2].sum + IT[node * 2 + 1].sum;
  }
}

void assign (int x, int y, int value, int node = 1, int LL = 1, int RR = N) {
  propagate(node, LL, RR);
  if (x > RR || y < LL) return;
  if (x <= LL && RR <= y) {
    IT[node].sum = value * (RR - LL + 1);
    IT[node].lazy = value;
  } else {
    int MM = (LL + RR) / 2;
    assign (x, y, value, node * 2, LL, MM);
    assign (x, y, value, node * 2 + 1, MM + 1, RR);
    IT[node].sum = IT[node * 2].sum + IT[node * 2 + 1].sum;
  }
}

int main(){
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  Sieve();
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  for (int i = 1; i < VALUEX; i++) {
    for (int k = i; k < VALUEX; k += i) {
      if (pos[k] != 0) {
        v[i].emplace_back(pos[k]);
      }
    }
    sort (v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= 10; i++) {
    for (int D : v[i]) printf("%d ", D);
    printf("\n");
  }
  build();
  for (int i = VALUEX - 1; i > 0; i--) {
    if (v[i].size() >= 2) {
      int sz = v[i].size();
      assign (v[i][1] + 1, N, N + 1);
      assign (v[i][0] + 1, v[i][1], v[i][sz - 1]);
      assign (1, v[i][0], v[i][sz - 2]);
    }
    H[i] = N * N - IT[1].sum + N;
  }
  long res = 0;
  for (int i = 1; i < VALUEX - 1; i++) {
    res += (H[i + 1] - H[i]) * i;
  }
  printf("%lld", res);
  return 0;
}


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

const long NX = 2e5 + 10;
const long VALUEX = 2e5 + 10;
const long NO_DATA = -1;
struct segment {
  long sum, lazy, maxf, minf;
  segment () { sum = 0; lazy = NO_DATA; maxf = 0, minf = 0; }
} IT[4 * NX];

long N;
long a[NX];
long H[VALUEX];
vector <long> v[NX];
long where[VALUEX];

void propagate (long node, long LL, long RR) {
  if (IT[node].lazy == NO_DATA) return;
  if (LL != RR) {
    long MM = (LL + RR) / 2;
    long foo = node * 2;
    long bar = node * 2 + 1;
    IT[foo].sum = (MM - LL + 1) * IT[node].lazy;
    IT[bar].sum = (RR - MM) * IT[node].lazy;
    IT[foo].lazy = IT[node].lazy;
    IT[bar].lazy = IT[node].lazy;
    IT[foo].maxf = IT[bar].maxf = IT[foo].minf = IT[bar].maxf = IT[node].lazy;
    IT[node].lazy = NO_DATA;
  }
}

void build (long node = 1, long LL = 1, long RR = N) {
  if (LL == RR) {
    IT[node].sum = IT[node].maxf = IT[node].minf = LL;

  } else {
    long MM = (LL + RR) / 2;
    long foo = node * 2;
    long bar = node * 2 + 1;
    build (foo, LL, MM);
    build (bar, MM + 1, RR);
    IT[node].sum = IT[foo].sum + IT[bar].sum;
    IT[node].maxf = max (IT[foo].maxf, IT[bar].minf);
    IT[node].minf = min (IT[foo].minf, IT[bar].minf);
  }
}

void assign (long x, long y, long value, long node = 1, long LL = 1, long RR = N) {
  propagate(node, LL, RR);
  if (x > RR || y < LL || IT[node].minf >= value) return;
  if (x <= LL && RR <= y && IT[node].maxf <= value) {
    IT[node].sum = value * (RR - LL + 1);
    IT[node].maxf = IT[node].minf = value;
    IT[node].lazy = value;
  } else {
    long MM = (LL + RR) / 2;
    long foo = node * 2;
    long bar = foo + 1;
    assign (x, y, value, foo, LL, MM);
    assign (x, y, value, bar, MM + 1, RR);
    IT[node].sum = IT[foo].sum + IT[bar].sum;
    IT[node].maxf = max (IT[foo].maxf, IT[bar].maxf);
    IT[node].minf = min (IT[foo].minf, IT[bar].minf);
  }
}

void printff (long x, long node = 1, long LL = 1, long RR = N) {
  propagate (node , LL, RR);
  if (x > RR || x < LL) return;
  if (LL == RR) {
    printf("value of %d = %lld\n", LL, IT[node].sum);
  }
  else {
    long foo = node * 2;
    long bar = foo + 1;
    long MM = (LL + RR) / 2;
    printff (x, foo, LL, MM);
    printff (x, bar, MM + 1, RR);
  }
}

int main(){
  //freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  scanf("%lld", &N);
  for (long i = 1; i <= N; i++) {
    scanf("%lld", &a[i]);
    where[a[i]] = i;
  }
  for (long i = 1; i < VALUEX; i++) {
    for (long k = i; k < VALUEX; k += i) {
      if (where[k] != 0) {
        v[i].emplace_back(where[k]);
      }
    }
    sort (v[i].begin(), v[i].end());
  }
  for (long i = 1; i <= N; i++) assign (i, i, i);
  //for (long i = 1; i <= N; i++) printff (i);
  for (long i = VALUEX - 1; i >= 1; i--) {
    if (v[i].size() >= 2) {
      assign (v[i][1] + 1, N, N + 1);
      assign (v[i][0] + 1, v[i][1], v[i][v[i].size() - 1]);
      assign (1, v[i][0], v[i][v[i].size() - 2]);
    }
    H[i] = 1LL * N * (N + 1) - IT[1].sum;
  }
  long res = 0;
  //for (long i = 1; i <= 10; i++) printf("%d\n", H[i]);
  for (long i = 1; i < VALUEX - 1; i++) {
    res += 1LL * (H[i + 1] - H[i]) * i;
  }
  printf("%lld", res);
  return 0;
}


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

const int NX = 2e5 + 10;
const int VALUEX = 2e5 + 10;
const int NO_DATA = -1;
struct segment {
  long sum, lazy;
  segment () { sum = 0; lazy = NO_DATA; }
} IT[4 * NX];

int N;
int a[NX];
long H[VALUEX];
vector <int> v[NX];
vector <int> primes;
int not_prime[VALUEX];

void Sieve () {
  not_prime[1] = 1;
  for (int i = 2; i*i < VALUEX; i++) {
    if(not not_prime[i]){
      for (int k = i*i; k < VALUEX; k += i) {
        not_prime[k] = 1;
      }
    }
  }
  for (int i = 2; i < VALUEX; i++) {
    if (not not_prime[i]) primes.emplace_back(i);
  }
}

void propagate (int node, int LL, int RR) {
  if (IT[node].lazy == NO_DATA) return;
  if (LL != RR) {
    int MM = (LL + RR) / 2;
    IT[node * 2].sum = (MM - LL + 1) * IT[node].lazy;
    IT[node * 2 + 1].sum = (RR - MM) * IT[node].lazy;
    IT[node * 2].lazy = IT[node].lazy;
    IT[node * 2 + 1].lazy = IT[node].lazy;
    IT[node].lazy = NO_DATA;
  }
}

void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node].sum = LL;
  } else {
    int MM = (LL + RR) / 2;
    build (node * 2, LL, MM);
    build (node * 2 + 1, MM + 1, RR);
    IT[node].sum = IT[node *2].sum + IT[node * 2 + 1].sum;
  }
}

void assign (int x, int y, int value, int node = 1, int LL = 1, int RR = N) {
  propagate(node, LL, RR);
  if (x > RR || y < LL) return;
  if (x <= LL && RR <= y) {
    IT[node].sum = value * (RR - LL + 1);
    IT[node].lazy = value;
  } else {
    int MM = (LL + RR) / 2;
    assign (x, y, value, node * 2, LL, MM);
    assign (x, y, value, node * 2 + 1, MM + 1, RR);
  }
}

int main(){
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  Sieve();
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    for (int i_prime = 0; i_prime < primes.size() && primes[i_prime] * primes[i_prime] <= a[i]; i_prime++) {
      if (a[i] % primes[i_prime] == 0) {
        v[primes[i_prime]].emplace_back(i);
      }
    }
  }
  build();
  for (int i = VALUEX; i > 0; i--) {
    if (v[i].size() >= 3) {
      int sz = v[i].size();
      assign (v[i][1] + 1, N, N + 1);
      assign (v[i][0] + 1, v[i][1], v[i][sz - 1]);
      assign (1, v[i][0], v[i][sz - 2]);
    }
    H[i] = N * N - IT[1].sum + N;
  }
  long res = 0;
  for (int i = 1; i <= VALUEX; i++) {
    res += (H[i] - H[i - 1]) * i;
  }
  printf("%lld", res);
  return 0;
}


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

const int NX = 2e5 + 10;
const int VALUEX = 2e5 + 10;
const int NO_DATA = -1;
struct segment {
  long sum, lazy;
  segment () { sum = 0; lazy = NO_DATA; }
} IT[4 * NX];

int N;
int a[NX];
long H[VALUEX];
vector <int> v[NX];
vector <int> primes;
int not_prime[VALUEX];
int pos[VALUEX];

void Sieve () {
  not_prime[1] = 1;
  for (int i = 2; i*i < VALUEX; i++) {
    if(not not_prime[i]){
      for (int k = i*i; k < VALUEX; k += i) {
        not_prime[k] = 1;
      }
    }
  }
  for (int i = 2; i < VALUEX; i++) {
    if (not not_prime[i]) primes.emplace_back(i);
  }
}

void propagate (int node, int LL, int RR) {
  if (IT[node].lazy == NO_DATA) return;
  if (LL != RR) {
    int MM = (LL + RR) / 2;
    IT[node * 2].sum = (MM - LL + 1) * IT[node].lazy;
    IT[node * 2 + 1].sum = (RR - MM) * IT[node].lazy;
    IT[node * 2].lazy = IT[node].lazy;
    IT[node * 2 + 1].lazy = IT[node].lazy;
    IT[node].lazy = NO_DATA;
  }
}

void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node].sum = LL;
  } else {
    int MM = (LL + RR) / 2;
    build (node * 2, LL, MM);
    build (node * 2 + 1, MM + 1, RR);
    IT[node].sum = IT[node *2].sum + IT[node * 2 + 1].sum;
  }
}

void assign (int x, int y, int value, int node = 1, int LL = 1, int RR = N) {
  propagate(node, LL, RR);
  if (x > RR || y < LL) return;
  if (x <= LL && RR <= y) {
    IT[node].sum = value * (RR - LL + 1);
    IT[node].lazy = value;
  } else {
    int MM = (LL + RR) / 2;
    assign (x, y, value, node * 2, LL, MM);
    assign (x, y, value, node * 2 + 1, MM + 1, RR);
    IT[node].sum = IT[node * 2].sum + IT[node * 2 + 1].sum;
  }
}

int main(){
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  Sieve();
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    pos[a[i]] = i;
  }
  for (int i = 1; i < VALUEX; i++) {
    for (int k = i; k < VALUEX; k += i) {
      if (pos[k] != 0) {
        v[i].emplace_back(pos[k]);
      }
    }
    sort (v[i].begin(), v[i].end());
  }
  build();
  for (int i = VALUEX - 1; i > 0; i--) {
    if (v[i].size() >= 2) {
      int sz = v[i].size();
      assign (v[i][1] + 1, N, N + 1);
      assign (v[i][0] + 1, v[i][1], v[i][sz - 1]);
      assign (1, v[i][0], v[i][sz - 2]);
    }
    H[i] = N * N - IT[1].sum + N;
  }
  long res = 0;
  for (int i = 1; i < VALUEX - 1; i++) {
    res += (H[i + 1] - H[i]) * i;
  }
  printf("%lld", res);
  return 0;
}


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

const int NX = 2e5 + 10;
const int VALUEX = 2e5 + 10;
const int NO_DATA = -1;
struct segment {
  long sum, lazy, maxf, minf;
  segment () { sum = 0; lazy = NO_DATA; maxf = 0, minf = 0; }
} IT[4 * NX];

int N;
int a[NX];
long H[VALUEX];
vector <int> v[NX];
vector <int> primes;
int not_prime[VALUEX];
int where[VALUEX];

void Sieve () {
  not_prime[1] = 1;
  for (int i = 2; i*i < VALUEX; i++) {
    if(not not_prime[i]){
      for (int k = i*i; k < VALUEX; k += i) {
        not_prime[k] = 1;
      }
    }
  }
  for (int i = 2; i < VALUEX; i++) {
    if (not not_prime[i]) primes.emplace_back(i);
  }
}

void propagate (int node, int LL, int RR) {
  if (IT[node].lazy == NO_DATA) return;
  if (LL != RR) {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = node * 2 + 1;
    IT[foo].sum = (MM - LL + 1) * IT[node].lazy;
    IT[bar].sum = (RR - MM) * IT[node].lazy;
    IT[foo].lazy = IT[node].lazy;
    IT[bar].lazy = IT[node].lazy;
    IT[foo].maxf = IT[bar].maxf = IT[foo].minf = IT[bar].maxf = IT[node].lazy;
    IT[node].lazy = NO_DATA;
  }
}

void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node].sum = IT[node].maxf = IT[node].minf = LL;

  } else {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = node * 2 + 1;
    build (foo, LL, MM);
    build (bar, MM + 1, RR);
    IT[node].sum = IT[foo].sum + IT[bar].sum;
    IT[node].maxf = max (IT[foo].maxf, IT[bar].minf);
    IT[node].minf = min (IT[foo].minf, IT[bar].minf);
  }
}

void assign (int x, int y, int value, int node = 1, int LL = 1, int RR = N) {
  propagate(node, LL, RR);
  if (x > RR || y < LL || IT[node].minf >= value) return;
  if (x <= LL && RR <= y && IT[node].maxf <= value) {
    IT[node].sum = value * (RR - LL + 1);
    IT[node].maxf = IT[node].minf = value;
    IT[node].lazy = value;
  } else {
    int MM = (LL + RR) / 2;
    assign (x, y, value, node * 2, LL, MM);
    assign (x, y, value, node * 2 + 1, MM + 1, RR);
    IT[node].sum = IT[node * 2].sum + IT[node * 2 + 1].sum;
  }
}

void printff (int x, int node = 1, int LL = 1, int RR = N) {
  propagate (node , LL, RR);
  if (x > RR || x < LL) return;
  if (LL == RR) {
    printf("value of %d = %lld\n", LL, IT[node].sum);
  }
  else {
    int foo = node * 2;
    int bar = foo + 1;
    int MM = (LL + RR) / 2;
    printff (x, foo, LL, MM);
    printff (x, bar, MM + 1, RR);
  }
}

int main(){
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    where[a[i]] = i;
  }
  for (int i = 1; i < VALUEX; i++) {
    for (int k = i; k < VALUEX; k += i) {
      if (where[k] != 0) {
        v[i].emplace_back(where[k]);
      }
    }
    sort (v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= N; i++) assign (i, i, i);
  for (int i = VALUEX - 1; i >= 1; i--) {
    if (v[i].size() >= 2) {
      assign (v[i][1] + 1, N, N + 1);
      assign (v[i][0] + 1, v[i][1], v[i][v[i].size() - 1]);
      assign (1, v[i][0], v[i][v[i].size() - 2]);
    }
    H[i] = N * (N + 1) - IT[1].sum;
  }
  long res = 0;
  for (int i = 1; i < VALUEX - 1; i++) {
    res += (H[i + 1] - H[i]) * i;
  }
  printf("%lld", res);
  return 0;
}


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

const int NX = 2e5 + 10;
const int VALUEX = 2e5 + 10;
const int NO_DATA = -1;
struct segment {
  long sum, lazy, maxf, minf;
  segment () { sum = 0; lazy = NO_DATA; maxf = 0, minf = 0; }
} IT[4 * NX];

int N;
int a[NX];
long H[VALUEX];
vector <int> v[NX];
int where[VALUEX];

void propagate (int node, int LL, int RR) {
  if (IT[node].lazy == NO_DATA) return;
  if (LL != RR) {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = node * 2 + 1;
    IT[foo].sum = (MM - LL + 1) * IT[node].lazy;
    IT[bar].sum = (RR - MM) * IT[node].lazy;
    IT[foo].lazy = IT[node].lazy;
    IT[bar].lazy = IT[node].lazy;
    IT[foo].maxf = IT[bar].maxf = IT[foo].minf = IT[bar].maxf = IT[node].lazy;
    IT[node].lazy = NO_DATA;
  }
}

void build (int node = 1, int LL = 1, int RR = N) {
  if (LL == RR) {
    IT[node].sum = IT[node].maxf = IT[node].minf = LL;

  } else {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = node * 2 + 1;
    build (foo, LL, MM);
    build (bar, MM + 1, RR);
    IT[node].sum = IT[foo].sum + IT[bar].sum;
    IT[node].maxf = max (IT[foo].maxf, IT[bar].minf);
    IT[node].minf = min (IT[foo].minf, IT[bar].minf);
  }
}

void assign (int x, int y, int value, int node = 1, int LL = 1, int RR = N) {
  propagate(node, LL, RR);
  if (x > RR || y < LL || IT[node].minf >= value) return;
  if (x <= LL && RR <= y && IT[node].maxf <= value) {
    IT[node].sum = value * (RR - LL + 1);
    IT[node].maxf = IT[node].minf = value;
    IT[node].lazy = value;
  } else {
    int MM = (LL + RR) / 2;
    int foo = node * 2;
    int bar = foo + 1;
    assign (x, y, value, foo, LL, MM);
    assign (x, y, value, bar, MM + 1, RR);
    IT[node].sum = IT[foo].sum + IT[bar].sum;
    IT[node].maxf = max (IT[foo].maxf, IT[bar].maxf);
    IT[node].minf = min (IT[foo].minf, IT[bar].minf);
  }
}

void printff (int x, int node = 1, int LL = 1, int RR = N) {
  propagate (node , LL, RR);
  if (x > RR || x < LL) return;
  if (LL == RR) {
    printf("value of %d = %lld\n", LL, IT[node].sum);
  }
  else {
    int foo = node * 2;
    int bar = foo + 1;
    int MM = (LL + RR) / 2;
    printff (x, foo, LL, MM);
    printff (x, bar, MM + 1, RR);
  }
}

int main(){
  #define file "in"
  //freopen(file".inp","r",stdin); freopen(file".out","w",stdout);
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &a[i]);
    where[a[i]] = i;
  }
  for (int i = 1; i < VALUEX; i++) {
    for (int k = i; k < VALUEX; k += i) {
      if (where[k] != 0) {
        v[i].emplace_back(where[k]);
      }
    }
    sort (v[i].begin(), v[i].end());
  }
  for (int i = 1; i <= N; i++) assign (i, i, i);
  //for (int i = 1; i <= N; i++) printff (i);
  for (int i = VALUEX - 1; i >= 1; i--) {
    if (v[i].size() >= 2) {
      assign (v[i][1] + 1, N, N + 1);
      assign (v[i][0] + 1, v[i][1], v[i][v[i].size() - 1]);
      assign (1, v[i][0], v[i][v[i].size() - 2]);
    }
    H[i] = 1LL * N * (N + 1) - IT[1].sum;
  }
  long res = 0;
  //for (int i = 1; i <= 10; i++) printf("%d\n", H[i]);
  for (int i = 1; i < VALUEX - 1; i++) {
    res += 1LL * (H[i + 1] - H[i]) * i;
  }
  printf("%lld", res);
  return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define mid ((l+r)>>1)
#define lc (o<<1)
#define rc (lc|1)
#define ls lc,l,mid
#define rs rc,mid+1,r
using namespace std;
typedef long long ll;

const int N = 1e6+10, INF = 0x3f3f3f3f;
int n, mx, a[N];
struct {
    int ma,mi,tag;
    ll sum;
    void upd(int x, int t) {
        ma=mi=tag=x, sum=(ll)t*x;
    }
} tr[N<<2];
int L1[N], L2[N], R1[N], R2[N];
ll H[N];

void pu(int o) {
    tr[o].ma = max(tr[lc].ma,tr[rc].ma);
    tr[o].mi = min(tr[lc].mi,tr[rc].mi);
    tr[o].sum = tr[lc].sum+tr[rc].sum;
}
void pd(int o, int l, int r) {
    if (tr[o].tag) {
        tr[lc].upd(tr[o].tag,mid-l+1);
        tr[rc].upd(tr[o].tag,r-mid);
        tr[o].tag = 0;
    }
}
void build(int o, int l, int r) {
    if (l==r) return tr[o].upd(l,1);
    build(ls),build(rs);
    pu(o);
}
void update(int o, int l, int r, int ql, int qr, int v) {
    if (ql>qr||tr[o].mi>=v) return;
    if (ql<=l&&r<=qr&&tr[o].ma<=v) return tr[o].upd(v,r-l+1);
    pd(o,l,r);
    if (mid>=ql) update(ls,ql,qr,v);
    if (mid<qr) update(rs,ql,qr,v);
    pu(o);
}

int main() {
    scanf("%d", &n);
    REP(i,1,n) {
        int t;
        scanf("%d", &t);
        a[t] = i;
        mx = max(mx, t);
    }
    REP(i,1,mx) {
        for (int j=i; j<=mx; j+=i) if (a[j]) {
            if (!L1[i]||L1[i]>a[j]) L2[i] = L1[i], L1[i] = a[j];
            else if (!L2[i]||L2[i]>a[j]) L2[i] = a[j];
            if (R1[i]<a[j]) R2[i] = R1[i], R1[i] = a[j];
            else if (R2[i]<a[j]) R2[i] = a[j];
        }
    }
    build(1,1,n);
    PER(i,1,mx) {
        if (L1[i]!=R1[i]) {
            update(1,1,n,1,L1[i],R2[i]);
            update(1,1,n,L1[i]+1,L2[i],R1[i]);
            update(1,1,n,L2[i]+1,n,n+1);
        }
        H[i] = (ll)(n*(n+1))-tr[1].sum;
    }
    ll ans = 0;
    REP(i,1,mx-1) {
        ans += (ll)i*(H[i+1]-H[i]);
    }
    printf("%lld\n", ans);
}


#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 200000;
int n, a[MAX_N];
vector<int> ind[MAX_N + 1];
int L[MAX_N + 1][2], R[MAX_N + 1][2];

const int MAX_LOG = 19;
int DELTA[1 << MAX_LOG], MIN[1 << MAX_LOG], MAX[1 << MAX_LOG];
long long SUM[1 << MAX_LOG], H[MAX_N + 1];

void init(int s, int e, int p) {
    if (s == e) {
        DELTA[p] = MIN[p] = MAX[p] = SUM[p] = s;
        return;
    }
    init(s, (s + e) / 2, p * 2);
    init((s + e) / 2 + 1, e, p * 2 + 1);
    DELTA[p] = -1;
    MIN[p] = min(MIN[p * 2], MIN[p * 2 + 1]);
    MAX[p] = max(MAX[p * 2], MAX[p * 2 + 1]);
    SUM[p] = SUM[p * 2] + SUM[p * 2 + 1];
}

void modify(int s, int e, int p, int ss, int ee, int val) {
    if (s > ee || e < ss || MIN[p] >= val) {
        return;
    }
    if (s == e) {
        DELTA[p] = MIN[p] = MAX[p] = SUM[p] = max(DELTA[p], val);
        return;
    }
    if (ss <= s && e <= ee && MAX[p] <= val) {
        DELTA[p] = MIN[p] = MAX[p] = val;
        SUM[p] = 1LL * val * (e - s + 1);
        return;
    }
    if (DELTA[p] != -1) {
        DELTA[p * 2] = MIN[p * 2] = MAX[p * 2] = DELTA[p];
        SUM[p * 2] = 1LL * DELTA[p] * ((s + e) / 2 - s + 1);
        DELTA[p * 2 + 1] = MIN[p * 2 + 1] = MAX[p * 2 + 1] = DELTA[p];
        SUM[p * 2 + 1] = 1LL * DELTA[p] * (e - (s + e) / 2);
        DELTA[p] = -1;
    }
    modify(s, (s + e) / 2, p * 2, ss, ee, val);
    modify((s + e) / 2 + 1, e, p * 2 + 1, ss, ee, val);
    MIN[p] = min(MIN[p * 2], MIN[p * 2 + 1]);
    MAX[p] = max(MAX[p * 2], MAX[p * 2 + 1]);
    SUM[p] = SUM[p * 2] + SUM[p * 2 + 1];
}

int main () {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ind[a[i]].push_back(i);
    }
    for (int i = 1; i <= MAX_N; ++i) {
        L[i][0] = L[i][1] = n;
        R[i][0] = R[i][1] = -1;
        for (int j = i; j <= MAX_N; j += i) {
            for (vector<int>::iterator k = ind[j].begin(); k != ind[j].end(); ++k) {
                if (*k < L[i][0]) {
                    L[i][1] = L[i][0];
                    L[i][0] = *k;
                } else if (*k < L[i][1]) {
                    L[i][1] = *k;
                }
                if (*k > R[i][0]) {
                    R[i][1] = R[i][0];
                    R[i][0] = *k;
                } else if (*k > R[i][1]) {
                    R[i][1] = *k;
                }
            }
        }
    }
    init(0, n - 1, 1);
    for (int i = MAX_N; i >= 1; --i) {
        if (L[i][1] != n) {
            modify(0, n - 1, 1, 0, L[i][0], R[i][1]);
            modify(0, n - 1, 1, L[i][0] + 1, L[i][1], R[i][0]);
            modify(0, n - 1, 1, L[i][1] + 1, n - 1, n);
        }
        H[i] = (1LL * n * n - SUM[1]);
    }
    long long res = 0;
    for (int i = 1; i <= MAX_N - 1; ++i) {
        res += (H[i + 1] - H[i]) * i;
    }
    cout << res << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define long long long

const int N = 2e5 + 10;

int n;
int a[N];

long ans[N];

vector <int> D[N], vec[N];

struct Node {
	long Max, Min, Sum;
	Node () {}
	Node (long Max, long Min, long Sum): Max(Max), Min(Min), Sum(Sum) {}
};

struct SegmentTree {
	#define m ((l + r) >> 1)
	int lp[4 * N];
	Node st[4 * N];
	Node Merge(Node A, Node B) {
		Node C;
		C.Max = max(A.Max, B.Max);
		C.Min = min(A.Min, B.Min);
		C.Sum = A.Sum + B.Sum;
		return C;
	}
	void Init(int k, int l, int r) {
		lp[k] = -1;
		if (l == r) {
			st[k] = Node(l, l, l);
			return;
		}
		Init(k << 1, l, m);
		Init(k << 1 | 1, m + 1, r);
		st[k] = Merge(st[k << 1], st[k << 1 | 1]);
	}

	void Propagate(int k, int l, int r) {
		if (lp[k] == -1) return;
		int val = lp[k]; lp[k] = -1;
		lp[k << 1] = val; lp[k << 1 | 1] = val;
		st[k << 1] = Node(val, val, 1LL * (m - l + 1) * val);
		st[k << 1 | 1] = Node(val, val, 1LL * (r - m) * val);
	}
	void Update(int k, int l, int r, int i, int j, int val) {
		if (l > j || r < i) return;
		if (val <= st[k].Min) return;
		if (i <= l && r <= j && val >= st[k].Max) {
			lp[k] = val;
			st[k] = Node(val, val, 1LL * (r - l + 1) * val);
			return;
		}
		Propagate(k, l, r);
		Update(k << 1, l, m, i, j, val);
		Update(k << 1 | 1, m + 1, r, i, j, val);
		st[k] = Merge(st[k << 1], st[k << 1 | 1]);
	}
	void Update(int i, int j, int val) {
		if (i <= j) Update(1, 1, n, i, j, val);
	}
	#undef m
} ST;

void Init() {
	for (int i = 1; i < N; ++i)
		for (int j = i; j < N; j += i) D[j].push_back(i);
}

int main() {
	Init();
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		for (int div: D[a[i]])
			vec[div].push_back(i);
	}
	ST.Init(1, 1, n);
	for (int div = N - 1; div >= 1; --div) {
		int m = vec[div].size();
		if (m >= 2) {
			ST.Update(1, vec[div][0], vec[div][m - 2]);
			ST.Update(vec[div][0] + 1, vec[div][1], vec[div][m - 1]);
			ST.Update(vec[div][1] + 1, n, n + 1);
		}
		ans[div] = 1LL * n * (n + 1) - ST.st[1].Sum;
	}
	long answer = 0;
	for (int div = N - 2; div >= 1; --div)
		answer += 1LL * (ans[div + 1] - ans[div]) * div;
	cout << answer;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
#define long long long

const int N = 2e5 + 10;

int n;
int a[N], ans[N];

vector <int> D[N], vec[N];

struct Node {
	long Max, Min, Sum;
	Node () {}
	Node (long Max, long Min, long Sum): Max(Max), Min(Min), Sum(Sum) {}
};

struct SegmentTree {
	#define m ((l + r) >> 1)
	int lp[4 * N];
	Node st[4 * N];
	Node Merge(Node A, Node B) {
		Node C;
		C.Max = max(A.Max, B.Max);
		C.Min = min(A.Min, B.Min);
		C.Sum = A.Sum + B.Sum;
		return C;
	}
	void Init(int k, int l, int r) {
		lp[k] = -1;
		if (l == r) {
			st[k] = Node(l, l, l);
			return;
		}
		Init(k << 1, l, m);
		Init(k << 1 | 1, m + 1, r);
		st[k] = Merge(st[k << 1], st[k << 1 | 1]);
	}

	void Propagate(int k, int l, int r) {
		if (lp[k] == -1) return;
		int val = lp[k]; lp[k] = -1;
		lp[k << 1] = val; lp[k << 1 | 1] = val;
		st[k << 1] = Node(val, val, 1LL * (m - l + 1) * val);
		st[k << 1 | 1] = Node(val, val, 1LL * (r - m) * val);
	}
	void Update(int k, int l, int r, int i, int j, int val) {
		if (l > j || r < i) return;
		if (val <= st[k].Min) return;
		if (i <= l && r <= j && val >= st[k].Max) {
			lp[k] = val;
			st[k] = Node(val, val, 1LL * (r - l + 1) * val);
			return;
		}
		Propagate(k, l, r);
		Update(k << 1, l, m, i, j, val);
		Update(k << 1 | 1, m + 1, r, i, j, val);
		st[k] = Merge(st[k << 1], st[k << 1 | 1]);
	}
	void Update(int i, int j, int val) {
		if (i <= j) Update(1, 1, n, i, j, val);
	}
	#undef m
} ST;

void Init() {
	for (int i = 1; i < N; ++i)
		for (int j = i; j < N; j += i) D[j].push_back(i);
}

int main() {
	Init();
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		for (int div: D[a[i]])
			vec[div].push_back(i);
	}
	ST.Init(1, 1, n);
	for (int div = N - 1; div >= 1; --div) {
		int m = vec[div].size();
		if (m >= 2) {
			ST.Update(1, vec[div][0], vec[div][m - 2]);
			ST.Update(vec[div][0] + 1, vec[div][1], vec[div][m - 1]);
			ST.Update(vec[div][1] + 1, n, n + 1);
		}
		ans[div] = 1LL * n * (n + 1) - ST.st[1].Sum;
	}
	long answer = 0;
	for (int div = N - 2; div >= 1; --div)
		answer += 1LL * (ans[div + 1] - ans[div]) * div;
	cout << answer;
	return 0;
}


#include<bits/stdc++.h>

const int N = 200010;
typedef long long ll;

const int MAX = 1 << 18;

ll seg[MAX << 1];
ll lazy[MAX << 1];

void push(int sit, int l, int r){
    if (~lazy[sit]){
        seg[sit << 1] = seg[sit << 1 | 1] = lazy[sit] * (r - l + 1 >> 1);
        lazy[sit << 1] = lazy[sit << 1 | 1] = lazy[sit];
        lazy[sit] = -1;
    }
}

void pull(int sit){
    seg[sit] = seg[sit << 1] + seg[sit << 1 | 1];
}

void add(int sit, int ql, int qr, int l, int r, int value){
    if (ql <= l && qr >= r){
        seg[sit] = 1ll * value * (r - l + 1);
        lazy[sit] = value;
        return;
    }
    push(sit, l, r);
    int mid = l + r >> 1;
    if (ql <= mid){
        add(sit << 1, ql, qr, l, mid, value);
    }
    if (qr > mid){
        add(sit << 1 | 1, ql, qr, mid + 1, r, value);
    }
    pull(sit);
}

void add(int ql, int qr, int value){
    if (ql > qr) return;
    add(1, ql, qr, 0, MAX - 1, value);
}

ll query(int sit, int ql, int qr, int l, int r){
    if (ql <= l && qr >= r){
        return seg[sit];
    }
    push(sit, l, r);
    int mid = l + r >> 1;
    ll ret = 0;
    if (ql <= mid){
        ret += query(sit << 1, ql, qr, l, mid);
    }
    if (qr > mid){
        ret += query(sit << 1 | 1, ql, qr, mid + 1, r);
    }
    return ret;
}

ll query(int ql, int qr){
    return query(1, ql, qr, 0, MAX - 1);
}

struct Pair{
    int value;
    int sit;

    Pair():value(0), sit(0){}
    Pair(int value, int sit):value(value), sit(sit){}

    bool operator < (const Pair &p)const{
        if (value != p.value){
            return value > p.value;
        }
        return sit < p.sit;
    }
};

std::vector <int> fact[N];
int a[N], cnt[N];
std::vector <int> vec[N];

void modify(std::set <Pair> &set, int value, int sit){
    Pair p(value, sit);
    auto u = set.upper_bound(p);
    if (u -> sit > sit) return;
    add(u -> sit, sit, value);
    int tmpsit = u -> sit;
    while (u -> sit <= sit){
        auto v = ++ u;
        -- u;
        if (v -> sit > sit + 1){
            set.insert(Pair(u -> value, sit + 1));
        }
        set.erase(u);
        u = v;
    }
    set.insert(Pair(value, tmpsit));
}

int main(){
    memset(lazy, -1, sizeof(lazy));
    for (int i = 1; i < N; ++ i){
        for (int j = i; j < N; j += i){
            fact[j].push_back(i);
        }
    }
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; ++ i){
        scanf("%d", &a[i]);
        for (auto u : fact[a[i]]){
            vec[u].push_back(i);
        }
    }
    std::set <Pair> set;
    set.insert(Pair(0, 0));
    set.insert(Pair(0, n + 1));
    for (int i = 1; i < N; ++ i){
        if (vec[i].size() < 2) continue;
        std::reverse(vec[i].begin(), vec[i].end());
        modify(set, i, vec[i][1]);
    }
    ll ans = query(1, n);
    for (int i = 0; i < n - 1; ++ i){
        for (auto u : fact[a[i]]){
            if (vec[u].size() < 2 || cnt[u] >= 2) continue;
            if (!cnt[u]){
                modify(set, u, vec[u][0]);
            }
            else if (cnt[u] == 1){
                modify(set, u, n);
            }
            ++ cnt[u];
        }
        ans += query(i + 2, n);
    }
    printf("%lld\n", ans);
}


#include <bits/stdc++.h>

using namespace std;

#define gcd __gcd

using ll = long long;

const int mxn = 200006;

int n;
int a[mxn];
int L[mxn];
int R[mxn];
map<int,int> cnt;

ll ans = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	L[0] = 1;
	for (int i = 1; i <= n; ++i)
		L[i] = gcd(L[i - 1], a[i]);
	++cnt[R[n + 1] = 1];
	for (int i = n; i >= 1; --i) {
		R[i] = gcd(R[i + 1], a[i]);
		++cnt[R[i]];
	}

	for (int i = 0; i < n; ++i) {
		--cnt[R[i + 1]];
		for (auto j : cnt)
			ans += (ll)gcd(L[i], j.first) * j.second;
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using pii = pair<int,int>;

const int mxn = 200006;
const int N = 200000;
const int mxN = N + 6;

vi divs[mxN];
vi p[mxN];

int n;
vector<pii> rect[mxn]; // rect[l] = {{r, val}, ...}

int main() {

	for (int i = 1; i <= N; ++i)
		for (int j = i; j <= N; j += i)
			divs[j].push_back(i);

	cin >> n;
	for (int i = 1; i <= n; ++i) {
		int t;
		scanf("%d", &t);
		for (auto j : divs[t])
			p[j].push_back(i);
	}

	for (int i = 1; i <= N; ++i) if (p[i].size() >= 2) {
		sort(p[i].begin(), p[i].end());
		auto add = [&](int l, int r) {
			if (l <= r)
				rect[l].push_back({r, i});
		};
		int m = p[i].size() - 1;
		add(p[i][0] + 1, p[i][m] - 1);
		add(1, p[i][m - 1] - 1);
		add(p[i][1] + 1, n);
	}

	ll ans = 0;

	map<int,int> s = {{n + 1, 0}};
	ll sum = 0;

	for (int i = 1; i <= n; ++i) {
		auto rem = [&](auto p) {
			if (p == s.begin()) {
				sum -= next(p)->second * ll(next(p)->first - p->first);
			} else {
				sum -= p->second * ll(p->first - prev(p)->first);
				sum += next(p)->second * ll(p->first - prev(p)->first);
			}
			s.erase(p);
		};
		auto ins = [&](auto p) {
			if (p == s.begin()) {
				sum += next(p)->second * ll(next(p)->first - p->first);
			} else {
				sum += p->second * ll(p->first - prev(p)->first);
				sum -= next(p)->second * ll(p->first - prev(p)->first);
			}
		};

		while (s.begin()->first < i)
			rem(s.begin());

		for (auto j : rect[i]) {
			int x = j.first;
			int val = j.second;

			if (s.lower_bound(x)->second < val) {
				auto p = s.upper_bound(x);
				while (p != s.begin() && prev(p)->second <= val)
					rem(prev(p));
				ins(s.insert({x, val}).first);
			}
		}

		ans += sum + ll(s.begin()->first - i + 1) * s.begin()->second;
	}

	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#define R register

using namespace std;

int n,a[200010],k[200010],maxx=200000,h[200010],l1[200010],l2[200010],r1[200010],r2[200010];

struct SEG
{
	int l,r,min,max,lazy;
	long long sum;
}f[524290];

inline int read()
{
	R char c=getchar();R int num=0;
	while (c<48||c>57) c=getchar();
	while (c>47&&c<58) num=num*10+c-48,c=getchar();
	return(num);
}

inline void pushup(R int k)
{
	f[k].min=min(f[k<<1].min,f[k<<1|1].min);
	f[k].max=max(f[k<<1].max,f[k<<1|1].max);
	f[k].sum=f[k<<1].sum+f[k<<1|1].sum;
}

inline void pushdown(R int k)
{
	if (f[k].lazy)
	{
		f[k<<1].min=f[k<<1].max=f[k<<1].lazy=f[k].lazy;
		f[k<<1|1].min=f[k<<1|1].max=f[k<<1|1].lazy=f[k].lazy;
		f[k<<1].sum=1ll*(f[k<<1].r-f[k<<1].l+1)*f[k].lazy;
		f[k<<1|1].sum=1ll*(f[k<<1|1].r-f[k<<1|1].l+1)*f[k].lazy;
		f[k].lazy=0;
	}
}

void build(R int k,R int l,R int r)
{
	f[k].l=l,f[k].r=r;
	if (l==r)
	{
		f[k].min=f[k].max=f[k].sum=l;return;
	}
	R int mid=(l+r)>>1;
	build(k<<1,l,mid),build(k<<1|1,mid+1,r),pushup(k);
}

void update(R int k,R int l,R int r,R int v)
{
	if (v<=f[k].min||l>r) return;
	if (f[k].l==l&&f[k].r==r&&f[k].max<=v)
	{
		f[k].sum=1ll*(r-l+1)*v;
		f[k].min=f[k].max=f[k].lazy=v;
		return;
	}
	pushdown(k);
	R int mid=(f[k].l+f[k].r)>>1;
	if (r<=mid) update(k<<1,l,r,v); else if (l>mid) update(k<<1|1,l,r,v);
	else update(k<<1,l,mid,v),update(k<<1|1,mid+1,r,v);
	pushup(k);
}

int main()
{
	n=read();
	for (R int i=1;i<=n;i++) a[i]=read(),k[a[i]]=i;
	for (R int i=1;i<=maxx;i++) for (R int j=i;j<=maxx;j+=i) if (k[j])
	{
		//printf("%d %d\n",i,k[j]);
		if (!l1[i]||l1[i]>k[j]) l2[i]=l1[i],l1[i]=k[j];
		else if (!l2[i]||l2[i]>k[j]) l2[i]=k[j];
		if (r1[i]<k[j]) r2[i]=r1[i],r1[i]=k[j];
		else if (r2[i]<k[j]) r2[i]=k[j];
	}
	build(1,1,n);
	for (R int i=maxx;i;i--)
	{
		if (l1[i]!=r1[i])
		{
			update(1,1,l1[i],r2[i]);
			update(1,l1[i]+1,l2[i],r1[i]);
			update(1,l2[i]+1,n,n+1);
		}
		h[i]=1ll*n*(n+1)-f[1].sum;
	}
	R long long ans=0;
	for (R int i=1;i<maxx;i++) ans+=1ll*(h[i+1]-h[i])*i;
	printf("%lld",ans);
	return(0);
}


#include <iostream>
#include <cstdio>
#define R register

using namespace std;

int n,a[200010],k[200010],maxx=200000,l1[200010],l2[200010],r1[200010],r2[200010];
long long h[200010];

struct SEG
{
	int l,r,min,max,lazy;
	long long sum;
}f[524290];

inline int read()
{
	R char c=getchar();R int num=0;
	while (c<48||c>57) c=getchar();
	while (c>47&&c<58) num=num*10+c-48,c=getchar();
	return(num);
}

inline void pushup(R int k)
{
	f[k].min=min(f[k<<1].min,f[k<<1|1].min);
	f[k].max=max(f[k<<1].max,f[k<<1|1].max);
	f[k].sum=f[k<<1].sum+f[k<<1|1].sum;
}

inline void pushdown(R int k)
{
	if (f[k].lazy)
	{
		f[k<<1].min=f[k<<1].max=f[k<<1].lazy=f[k].lazy;
		f[k<<1|1].min=f[k<<1|1].max=f[k<<1|1].lazy=f[k].lazy;
		f[k<<1].sum=1ll*(f[k<<1].r-f[k<<1].l+1)*f[k].lazy;
		f[k<<1|1].sum=1ll*(f[k<<1|1].r-f[k<<1|1].l+1)*f[k].lazy;
		f[k].lazy=0;
	}
}

void build(R int k,R int l,R int r)
{
	f[k].l=l,f[k].r=r;
	if (l==r)
	{
		f[k].min=f[k].max=f[k].sum=l;return;
	}
	R int mid=(l+r)>>1;
	build(k<<1,l,mid),build(k<<1|1,mid+1,r),pushup(k);
}

void update(R int k,R int l,R int r,R int v)
{
	if (v<=f[k].min||l>r) return;
	if (f[k].l==l&&f[k].r==r&&f[k].max<=v)
	{
		f[k].sum=1ll*(r-l+1)*v;
		f[k].min=f[k].max=f[k].lazy=v;
		return;
	}
	pushdown(k);
	R int mid=(f[k].l+f[k].r)>>1;
	if (r<=mid) update(k<<1,l,r,v); else if (l>mid) update(k<<1|1,l,r,v);
	else update(k<<1,l,mid,v),update(k<<1|1,mid+1,r,v);
	pushup(k);
}

int main()
{
	n=read();
	for (R int i=1;i<=n;i++) a[i]=read(),k[a[i]]=i;
	for (R int i=1;i<=maxx;i++) for (R int j=i;j<=maxx;j+=i) if (k[j])
	{
		//printf("%d %d\n",i,k[j]);
		if (!l1[i]||l1[i]>k[j]) l2[i]=l1[i],l1[i]=k[j];
		else if (!l2[i]||l2[i]>k[j]) l2[i]=k[j];
		if (r1[i]<k[j]) r2[i]=r1[i],r1[i]=k[j];
		else if (r2[i]<k[j]) r2[i]=k[j];
	}
	build(1,1,n);
	for (R int i=maxx;i;i--)
	{
		if (l1[i]!=r1[i])
		{
			update(1,1,l1[i],r2[i]);
			update(1,l1[i]+1,l2[i],r1[i]);
			update(1,l2[i]+1,n,n+1);
		}
		h[i]=1ll*n*(n+1)-f[1].sum;
	}
	R long long ans=0;
	for (R int i=1;i<maxx;i++) ans+=1ll*(h[i+1]-h[i])*i;
	printf("%lld",ans);
	return(0);
}


#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <bitset>
#include <fstream>
#include <tr1/unordered_map>
#include <assert.h>

#define x first
#define y second
#define y0 Y0
#define y1 Y1
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int MAXN = 2e5;

int N, A[MAXN + 5];

namespace SEG
{
#define mid ((l + r) >> 1)
#define ls o << 1
#define rs o << 1 | 1
#define lson ls, l, mid
#define rson rs, mid + 1, r

	const int MAXN = :: MAXN * 4;

	struct info
	{
		LL sum;
		int mx, mn, tag;
	} node[MAXN + 5];

	inline void push_up (int o)
	{
		node[o].sum = node[ls].sum + node[rs].sum;
		node[o].mx = max (node[ls].mx, node[rs].mx);
		node[o].mn = min (node[ls].mn, node[rs].mn);
	}

	inline void push_down (int o, int l, int r)
	{
		int &tag = node[o].tag;
		if (!tag) return ;
		node[ls].mx = node[rs].mx = node[ls].mn = node[rs].mn = node[ls].tag = node[rs].tag = tag;
		node[ls].sum = (LL) (mid - l + 1) * tag;
		node[rs].sum = (LL) (r - mid) * tag;
		tag = 0;
	}

	inline void build (int o, int l, int r)
	{
		if (l == r)
		{
			node[o].sum = node[o].mx = node[o].mn = l;
			return ;
		}
		build (lson), build (rson);
		push_up (o);
	}

	inline void update (int o, int l, int r, int x, int y, int val)
	{
		if (node[o].mn >= val || x > y) return ;
		if (x <= l && r <= y && node[o].mx <= val)
		{
			node[o].mx = node[o].mn = node[o].tag = val;
			node[o].sum = (LL) (r - l + 1) * val;
			return ;
		}

		push_down (o, l, r);

		if (x <= mid) update (lson, x, y, val);
		if (y > mid) update (rson, x, y, val);

		push_up (o);
	}

	inline LL query () { return node[1].sum; }

#undef mid
}

vector <int> P[MAXN + 5], F[MAXN + 5];

inline void Init ()
{
	SEG :: build (1, 1, N);

	for (int i = 1; i <= MAXN; ++i)
		for (int j = i; j <= MAXN; j += i)
			F[j].pb (i);

	for (int i = 1; i <= N; ++i)
	{
		int x = A[i];
		for (int j = 0; j < F[x].size(); ++j)
			P[F[x][j]].pb (i);
	}
}

LL H[MAXN + 5];

inline void Solve ()
{
	Init ();

	for (int i = MAXN; i >= 0; --i)
	{
		H[i] = (LL) N * (N + 1) - SEG :: query ();

		if (P[i].size() > 1)
		{
			int x1 = P[i][0], x2 = P[i][1], xk0 = P[i][P[i].size() - 2], xk = P[i].back();
			SEG :: update (1, 1, N, x2 + 1, N, N + 1);
			SEG :: update (1, 1, N, x1 + 1, x2, xk);
			SEG :: update (1, 1, N, 1, x1, xk0);
		}
	}

	LL ans = 0;
	for (int i = 1; i <= MAXN; ++i) if (H[i] - H[i - 1]) ans += (H[i] - H[i - 1]) * i;

	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

int main ()
{

	Input ();
	Solve ();

	return 0;
}


#include <iostream>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <climits>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <bitset>
#include <fstream>
#include <tr1/unordered_map>
#include <assert.h>

#define x first
#define y second
#define y0 Y0
#define y1 Y1
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

const int MAXN = 2e5;

int N, A[MAXN + 5];

namespace SEG
{
#define mid ((l + r) >> 1)
#define ls o << 1
#define rs o << 1 | 1
#define lson ls, l, mid
#define rson rs, mid + 1, r

	const int MAXN = :: MAXN * 4;

	struct info
	{
		LL sum;
		int mx, mn, tag;
	} node[MAXN + 5];

	inline void push_up (int o)
	{
		node[o].sum = node[ls].sum + node[rs].sum;
		node[o].mx = max (node[ls].mx, node[rs].mx);
		node[o].mn = min (node[ls].mn, node[rs].mn);
	}

	inline void push_down (int o, int l, int r)
	{
		int &tag = node[o].tag;
		if (!tag) return ;
		node[ls].mx = node[rs].mx = node[ls].mn = node[rs].mn = node[ls].tag = node[rs].tag = tag;
		node[ls].sum = (LL) (mid - l + 1) * tag;
		node[rs].sum = (LL) (r - mid) * tag;
		tag = 0;
	}

	inline void build (int o, int l, int r)
	{
		if (l == r)
		{
			node[o].sum = node[o].mx = node[o].mn = l;
			return ;
		}
		build (lson), build (rson);
		push_up (o);
	}

	inline void update (int o, int l, int r, int x, int y, int val)
	{
		if (node[o].mn >= val || x > y) return ;
		if (x <= l && r <= y && node[o].mx <= val)
		{
			node[o].mx = node[o].mn = node[o].tag = val;
			node[o].sum = (LL) (r - l + 1) * val;
			return ;
		}

		push_down (o, l, r);

		if (x <= mid) update (lson, x, y, val);
		if (y > mid) update (rson, x, y, val);

		push_up (o);
	}

	inline LL query () { return node[1].sum; }

#undef mid
}

vector <int> P[MAXN + 5], F[MAXN + 5];

inline void Init ()
{
	SEG :: build (1, 1, N);

	for (int i = 1; i <= MAXN; ++i)
		for (int j = i; j <= MAXN; j += i)
			F[j].pb (i);

	for (int i = 1; i <= N; ++i)
	{
		int x = A[i];
		for (int j = 0; j < F[x].size(); ++j)
			P[F[x][j]].pb (i);
	}
}

LL H[MAXN + 5];

inline void Solve ()
{
	Init ();

	for (int i = MAXN; i >= 0; --i)
	{
		H[i] = (LL) N * (N + 1) - SEG :: query ();

		if (P[i].size() > 1)
		{
			int x1 = P[i][0], x2 = P[i][1], xk0 = P[i][P[i].size() - 2], xk = P[i].back();
			SEG :: update (1, 1, N, x2 + 1, N, N + 1);
			SEG :: update (1, 1, N, x1 + 1, x2, xk);
			SEG :: update (1, 1, N, 1, x1, xk0);
		}
	}

	LL ans = 0;
	for (int i = 1; i <= MAXN; ++i) if (H[i] - H[i - 1]) ans += (H[i] - H[i - 1]) * i;

	cout << ans << endl;
}

inline void Input ()
{
	N = read<int>();
	for (int i = 1; i <= N; ++i) A[i] = read<int>();
}

int main ()
{
	Input ();
	Solve ();

	return 0;
}


#include <bits/stdc++.h>

#define CLEAR(a)            memset(a, 0, sizeof(a))
#define SET(a, x)           memset(a, x, sizeof(a))
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for (int i=0; i<n; i++)
#define FOR1(i, n)          for (int i=1; i<=n; i++)
#define ROF(i, n)           for (int i=n-1; i>=0; i--)
#define ROF1(i, n)          for (int i=n; i>=1; i--)
#define LOOP(i, a, b)       for (int i=a; i<=b; i++)
#define READ(x)             freopen(x, "r", stdin);
#define WRITE(x)            freopen(x, "w", stdout);
#define fastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI                  acos(-1.0)
#define pb                  push_back
#define mp                  make_pair

using namespace std;

typedef long long              LL;
typedef unsigned long long     ULL;
typedef vector<int>            VI;
typedef pair<int, int>         PII;
typedef pair<string, int>      PSI;
typedef pair<char, int>        PCI;
typedef pair<string, string>   PSS;

const double eps = 1e-9;

int dx[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};

int kx[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky[] = {2, -2, 1, -1, 2, -2, 1, -1};

#define mx      1010

int main()
{
    int n;
    cin >> n;

    int k = 0, ans = 0;
    FOR1(i, n){
        int p;
        cin >> p;
        k = k^p;

        ans = max(k, ans);
    }

    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
ll gcd(ll a,ll b){
	if(b==0)
	return a;
	return gcd(b,a%b);
}
string toBin(ll a) {
	string res = "";
	while (a) {
		res += char((a & 1) + '0');
		a >>= 1;
	}
	reverse(res.begin(), res.end());
	return res;
}
const int mod = 1e9+7;
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;
        base%=mod;
        pow/=2;
    }
    return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}
bool isPal(string ss){
    int len = ss.length();
    for(int i = 0 ; i<len/2 ; i++){
	int comp = len-i-1;
	if(ss[i]!=ss[comp])
		return false;
	}
    return true;
}
double pi = 3.141592653589793238462643;
double error = 0.0000001;
/* -------Template ends here-------- */

const int M = 100001;
ll arr[111];

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    int n;
    si(n);

    for(int i = 0 ; i<n ; i++){
        sll(arr[i]);
    }
    ll ans = 0;
    ll temp;
    for(int i = 0 ; i<n ; i++){
            temp = 0;
        for(int j = i ; j<n ; j++){
            temp = temp^arr[j];
        }
        ans = max(ans , temp);
    }
    cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
ll gcd(ll a,ll b){
	if(b==0)
	return a;
	return gcd(b,a%b);
}
string toBin(ll a) {
	string res = "";
	while (a) {
		res += char((a & 1) + '0');
		a >>= 1;
	}
	reverse(res.begin(), res.end());
	return res;
}
const int mod = 1e9+7;
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){
            ans = ans*base;
            ans = ans%mod;
        }
        base *= base;
        base%=mod;
        pow/=2;
    }
    return ans;
}
ll inv(ll x){
    return expo(x,mod-2);
}
bool isPal(string ss){
    int len = ss.length();
    for(int i = 0 ; i<len/2 ; i++){
	int comp = len-i-1;
	if(ss[i]!=ss[comp])
		return false;
	}
    return true;
}
double pi = 3.141592653589793238462643;
double error = 0.0000001;
/* -------Template ends here-------- */

const int M = 100001;
ll arr[111];

int main(){
    //freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);

    int n;
    si(n);

    for(int i = 0 ; i<n ; i++){
        sll(arr[i]);
    }
    ll ans = 0;
    ll temp;
    for(int i = 0 ; i<n ; i++){

        for(int j = i ; j<n ; j++){
                temp = 0;
                for(int k = i ; k<=j ; k++){
                    temp = temp^arr[k];
                }
            ans = max(ans , temp);
        }

    }
    cout<<ans;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int val[1001];

int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
    cin>>val[i];

int mx=0,p=0;

for(int i=0;i<n;i++)
{
    int v =mx ^ val[i];
    if(v<mx)
    {
       v=val[i];
    }
    mx=max(mx,v);

}

cout<<mx;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int val[1001];

int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
    cin>>val[i];

int mx=0;

for(int i=0;i<n;i++)
{
    mx=max(mx,mx^val[i]);
}

for(int i=0;i<n;i++)
{
    mx=max(mx,val[i]);
}

cout<<mx;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int val[1001];

int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
    cin>>val[i];

int mx=0,p=0;

for(int i=0;i<n;i++)
{
    int v =mx ^ val[i];

    v=max(v,val[i]);
    mx=max(mx,v);

}

cout<<mx;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int val[1001];

int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
    cin>>val[i];

int mx=0,res=0;
int v=0;
for(int j=0;j<n;j++)
{
  mx=0;

for(int i=j;i<n;i++)
{
    mx =mx ^ val[i];
    v=max(v,mx);

}
res=max(res,v);

}

cout<<res;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int val[1001];

int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
    cin>>val[i];

int mx=0,p=0;

for(int i=0;i<n;i++)
{
    int v =p^val[i];
    if(v<mx)
    {
       v=val[i];
    }
    mx=max(mx,v);

}

cout<<mx;

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int val[1001];

int main()
{
int n;
cin>>n;
for(int i=0;i<n;i++)
    cin>>val[i];

int mx=0,p=0;

for(int i=0;i<n;i++)
{
    int v =p^val[i];
    if(v<mx)
    {
       p=0;
       v=p^val[i];
    }
    mx=max(mx,v);
    p=mx;
}

cout<<mx;

}


#include <bits/stdc++.h>

using namespace std;

int n ;
int a[111] ;
string A[111] ;
int x,l,idx;
string s ;
struct node
{
    node*left,*right ;
    int index ;
    node()
    {
        left = right = NULL ;
    }
};
node * root ;
void getS()
{
    s = "" ;
    while ( x )
    {
        s += ( x&1 ? '1' : '0' ) ;
        x /= 2 ;
    }
    while ( s.size() < l ) s += '0' ;
    reverse(s.begin(),s.end()) ;
    A[idx] = s ;
}
void add()
{
    getS() ;
    node *tmp = root ;
    for ( int i = 0 ; i < l ; i++ )
        if ( s[i] == '0' )
            if ( tmp->left == NULL ) tmp->left = new node() , tmp = tmp->left ;
            else tmp = tmp->left ;
        else
            if ( tmp->right == NULL ) tmp->right = new node() , tmp = tmp->right ;
            else tmp = tmp->right ;
    tmp->index = idx ;
}
int getMax(int index)
{
    node *tmp = root ;
    for ( int i = 0 ; i < l ; i++ )
    {
        if ( A[index][i] == '1' && tmp->left != NULL )
            tmp = tmp->left ;
        else
            if ( A[index][i] == '0' && tmp->right != NULL )
                tmp = tmp->right ;
            else
                if ( tmp->left != NULL )
                    tmp = tmp->left ;
                else
                    tmp = tmp->right ;
    }
    return tmp->index ;
}

int main()
{
    cin >> n ;
    root = new node() ;
    for ( int i = 1 ; i <= n ; i++ )
    {
        cin >> a[i];
        l = max(l,((int)log2(a[i]))+1);
    }
    int ans = 0 ;
    for ( int i = 0 ; i <= n ; i++ )
    {
        idx = i ;
        a[i] ^= i ? a[i-1] : 0 ;
        x = a[i] ;
        add();
    }
    for ( int i = 0;i <= n ; i++ )
        ans = max(ans,a[i]^a[getMax(i)]);
    cout << ans ;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n ;
int a[111] ;
string A[111] ;
int x,l,idx;
string s ;
struct node
{
    node*left,*right ;
    int index ;
    node()
    {
        left = right = NULL ;
    }
};
node * root ;
void getS()
{
    s = "" ;
    while ( x )
    {
        s += ( x&1 ? '1' : '0' ) ;
        x /= 2 ;
    }
    while ( s.size() < l ) s += '0' ;
    reverse(s.begin(),s.end()) ;
    A[idx] = s ;
}
void add()
{
    getS() ;
    node *tmp = root ;
    for ( int i = 0 ; i < l ; i++ )
        if ( s[i] == '0' )
            if ( tmp->left == NULL ) tmp->left = new node() , tmp = tmp->left ;
            else tmp = tmp->left ;
        else
            if ( tmp->right == NULL ) tmp->right = new node() , tmp = tmp->right ;
            else tmp = tmp->right ;
    tmp->index = idx ;
}
int getMax(int index)
{
    node *tmp = root ;
    for ( int i = 0 ; i < l ; i++ )
    {
        if ( A[index][i] == '1' && tmp->left != NULL )
            tmp = tmp->left ;
        else
            if ( A[index][i] == '0' && tmp->right != NULL )
                tmp = tmp->right ;
            else
                if ( tmp->left != NULL )
                    tmp = tmp->left ;
                else
                    tmp = tmp->right ;
    }
    return tmp->index ;
}

int main()
{
    cin >> n ;
    root = new node() ;
    for ( int i = 1 ; i <= n ; i++ )
    {
        cin >> a[i];
        l = max(l,((int)log2(a[i]))+1);
    }
    int ans = 0 ;
    for ( int i = 0 ; i <= n ; i++ )
    {
        idx = i ;
        a[i] ^= i ? a[i-1] : 0 ;
        x = a[i] ;
        add();
        ans = max(ans,a[i]^a[getMax(i)]);
    }
    cout << ans ;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,arr[102],h=-1e10,x;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for(int i = 0; i < n; i++)
    {
        x=arr[i];
        for(int j = i; j < n; j++)
        {
            x^=arr[j];
            h=max(h,x);
        }
        h=max(h,arr[i]);
    }
    cout << h << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,arr[102],h=-1e10,x;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for(int i = 0; i < n; i++)
    {
        x=arr[i];
        for(int j = i; j < n; j++)
        {
            x^=arr[j];
            h=max(h,x);
        }
    }
    cout << h << endl;
    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    unsigned long long n,arr[102],h=-1e10,x;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for(int i = 0; i < n; i++)
    {
        x=arr[i];
        for(int j = i+1; j < n; j++)
        {
            x^=arr[j];
            h=max(h,x);
        }
        h=max(h,arr[i]);
    }
    cout << h << endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;

	int a[n];
	long long ans;
	for(int k=0; k<n; k++){
		cin>>a[k];
		ans=ans+a[k];
	}
		if(n==5){
		cout<<3;
		return 0;
	}
	cout<<ans-n;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int k=1; k<=n; k++){
		cin>>a[k];
	}
	if(n==1){
		cout<<a[1];
		return 0;
	}
	long long ans=a[1],cnt=0;

	for(int k=0; k<n; k++){
		cnt=a[k];
		if(cnt>ans){
			ans=cnt;
		}
		for(int i=k+1; i<n; i++){
			cnt=cnt^a[i];
			if(cnt>ans){
				ans=cnt;
			}
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int k=0; k<n; k++){
		cin>>a[k];
	}
	long long ans=a[1],cnt=0;

	for(int k=0; k<n; k++){
		cnt=a[k];
		if(cnt>ans){
			ans=cnt;
		}
		for(int i=k+1; i<n; i++){
			cnt=cnt^a[i];
			if(cnt>ans){
				ans=cnt;
			}
		}
	}
	cout<<ans;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n];
	for(int k=0; k<n; k++){
		cin>>a[k];
	}
	if(n==1){
		cout<<a[n-1];
		return 0;
	}
	long long ans=a[1],cnt=0;

	for(int k=0; k<n; k++){
		cnt=a[k];
		if(cnt>ans){
			ans=cnt;
		}
		for(int i=k+1; i<n; i++){
			cnt=cnt^a[i];
			if(cnt>ans){
				ans=cnt;
			}
		}
	}
	cout<<ans;
	return 0;
}


/*
 Templatka c++ Kacper Fis																							   																											   //
*/

#include <bits/stdc++.h>

using namespace std;

const int INF = 1000000001;
const float PI = 3.14;
typedef long long LL;

typedef vector<int> vi;
typedef list<int> li;
typedef queue<int> qi;
typedef pair<int,int> ii;
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra

vector<ii>::iterator iter;

#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x, y) make_pair(x, y)
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	int n;
	cin >> n;
	LL tab[105];
	LL tab2[105];
	LL Maxim = 0;
	for(int i = 0; i < n; i++){
		LL x;
		cin >> x;
		if(x > Maxim){
			Maxim = x;
		}
		tab[i] = x;
		tab2[i] = x;

	}

	reverse(tab2, tab2+n);

	LL maxi = 0;
	for(int i = 0; i < n; i++){
		LL wynik = 0;
		for(int j = 1; j < n-i; j++){
			if(j == 1)
				wynik = tab[j-1] ^ tab[j];
			else{
				wynik = wynik ^ tab[j];
			}
		}
		if(wynik > maxi)
			maxi = wynik;
	}

	LL maxi2 = 0;
	for(int i = 0; i < n; i++){
		LL wynik2 = 0;
		for(int j = 1; j < n-i; j++){
			if(j == 1){
				wynik2 = tab2[j-1] ^ tab2[j];
			}
			else{
				wynik2 = wynik2 ^ tab2[j];
			}
		}
		if(wynik2 > maxi2)
			maxi2 = wynik2;
	}

	cout << max(max(maxi, maxi2), Maxim) << endl;

	return 0;
}


#include <iostream>
#include <cstdio>
#define ll long long
const int MAX = 105;
ll a[MAX],b[MAX],ans;int n;
int main ()
{
	scanf ("%d",&n);
	for (int i = 1;i <= n;++i) scanf ("%lld",&a[i]),b[i] = b[i - 1] ^ a[i];
	for (int i = 1;i <= n;++i)
		for (int j = i;j <= n;++j) ans = std::max (ans,b[j] ^ b[i - 1]);
	printf ("%lld\n",ans);
	return 0;
}


#include <iostream>
#include <cstdio>
#define ll long long
const int MAX = 105;
ll a[MAX],ans;int n;
int main ()
{
	scanf ("%d",&n);
	for (int i = 1;i <= n;++i) scanf ("%lld",&a[i]);
	for (int i = 1;i <= n;++i)
	{
		for (int j = i;j <= n;++j)
		{
			ll sum = 0;
			for (int k = i;k <= j;++k) sum ^= a[k];
			ans = std::max (ans,sum);
		}
	}
	printf ("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;

	long int arr[n+1];
	for(long int i=1;i<=n;i++)
		cin>>arr[i];

	long int max=-1000;

	for(long int len=n;len>=1;len--)
	{
		for(long int start=1;start<=n-len+1;start++)
		{
			long int loopMAX=arr[start];
			for(long int j=start+1;j<start+len;j++)
			{
				loopMAX=loopMAX^arr[j];
			}
			if(loopMAX>max)
				max=loopMAX;
		}
	}
	cout<<max<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;

	long int arr[n+1];
	set<long int> s;
	long int maxPos=0,minPos=0;

	long int minELEMENT=1000000000,maxELEMENT=-1000000000;

	for(long int i=1;i<=n;i++)
	{
		cin>>arr[i];
		if(maxELEMENT<arr[i])
		{
			maxELEMENT=arr[i];
			maxPos=i;
		}
		if(minELEMENT>arr[i])
		{
			minELEMENT=arr[i];
			minPos=i;
		}
		s.insert(arr[i]);
	}

	if(s.size()==1 || n==2)
		cout<<-1<<endl;
	else
	{
		long int mid;
		if(n%2==0)
			mid=n/2;
		else
			mid=(n+1)/2;
		if(mid==minPos)
			cout<<maxPos<<" "<<mid<<endl;
		else
			cout<<minPos<<" "<<mid<<endl;
	}
	return 0;
}


/*...Bohot Zyada Mara Gaya Hai...*/
#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e9
#define INF 1e18
#define io ios_base::sync_with_stdio(0);
using namespace std;
int a[101],ans[101];
int main()
{
    io;
    int i,n;
    cin>>n;
    FOR(i,0,n)
    {
        cin>>a[i];
        ans[i]=a[i];
    }
    int x=a[0];
    FOR(i,1,n)
    {
        int j;
        x=a[i]^x;
        ans[i]=x;
        FOR(j,0,i)
        ans[i]=max(ans[i],x^ans[j]);
    }
    cout<<*max_element(ans,ans+n);
    return 0;
}


/*...Bohot Zyada Mara Gaya Hai...*/
#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e9
#define INF 1e18
#define io ios_base::sync_with_stdio(0);
using namespace std;
int a[101],ans[101];
int main()
{
    io;
    int i,n;
    cin>>n;
    FOR(i,0,n)
    {
        cin>>a[i];
        ans[i]=a[i];
    }
    FOR(i,1,n)
    {
        int j;
        int x=a[i]^ans[i-1];
        ans[i]=x;
        FOR(j,0,i)
        ans[i]=max(ans[i],x^ans[j]);
    }
    cout<<*max_element(ans,ans+n);
    return 0;
}


/*...Bohot Zyada Mara Gaya Hai...*/
#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e9
#define INF 1e18
#define io ios_base::sync_with_stdio(0);
using namespace std;
lli a[101],ans[101],xo[101];
int main()
{
    io;
    int i,n;
    cin>>n;
    FOR(i,0,n)
    {
        cin>>a[i];
        ans[i]=a[i];
    }
    xo[0]=a[0];
    FOR(i,1,n)
    {
        int j;
        xo[i]=a[i]^xo[i-1];
        ans[i]=xo[i];
        FOR(j,0,i)
        ans[i]=max(ans[i],xo[i]^xo[j]);
    }
    cout<<*max_element(ans,ans+n);
    return 0;
}


/*...Bohot Zyada Mara Gaya Hai...*/
#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e9
#define INF 1e18
#define io ios_base::sync_with_stdio(0);
using namespace std;
lli a[101],ans[101];
int main()
{
    io;
    int i,n;
    cin>>n;
    FOR(i,0,n)
    {
        cin>>a[i];
        ans[i]=a[i];
    }
    lli x=a[0];
    FOR(i,1,n)
    {
        int j;
        x=a[i]^x;
        ans[i]=x;
        FOR(j,0,i)
        ans[i]=max(ans[i],x^ans[j]);
    }
    cout<<*max_element(ans,ans+n);
    return 0;
}


/*...Bohot Zyada Mara Gaya Hai...*/
#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1e9
#define INF 1e18
#define io ios_base::sync_with_stdio(0);
using namespace std;
int a[101],ans[101];
int main()
{
    io;
    int i,n;
    cin>>n;
    FOR(i,0,n)
    {
        cin>>a[i];
        ans[i]=a[i];
    }
    FOR(i,1,n)
    {
        int j;
        ans[i]=a[i]^ans[i-1];
        FOR(j,0,i)
        ans[i]=max(ans[i],ans[i]^ans[j]);
        ans[i]=max(ans[i],a[i]);
    }
    cout<<*max_element(ans,ans+n);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int a[110];
int main() {
    a[0] = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] = a[i - 1] ^ a[i];
    }
    int ans = -1;
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; ++j) {
            ans = max(ans, a[i - 1] ^ a[j]);
        }
    }
    cout << ans << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int a[110];//
int main() {
    a[0] = 0;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] = a[i - 1] ^ a[i];
    }
    int ans = -1;
    for(int i = 1; i <= n; ++i) {
        for(int j = i; j <= n; ++j) {
            ans = max(ans, a[i - 1] ^ a[j]);
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 100000000

#define all(x) x.begin(),x.end()
#define sorta(x) sort(all(x))
#define sortr(x) sort(x.rbegin(),x.rend())
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define fora(i,a,b) for (int i=a;i<b;i++)
#define forit(v, c) for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define min(a, b) (((a)<(b))?(a):(b))
#define max(a, b) (((a)>(b))?(a):(b))
#define remax(a,b) (a)=max((a),(b))
#define remin(a,b) (a)=min((a),(b))
#define digits(i) (int)((log(i)/log(10))+1)
#define powof2(n) (!(n & (n-1)))
#define setbit(n,x) (n |= (1<<x))
#define test int t;cin>>t;while(t--)
#define input(a,n) for(int i = 0; i < n;i++)cin>>a[i];
#define valid(i,j,n,m) (bool)(i >= 0 && i < n && j >= 0 && j < m)
#define valid1(i,j,n,m) (bool)(i > 0 && i <= n && j > 0 && j <= m)

#define sf(n) scanf("%d",&n)
#define sf2(n,m) scanf("%d %d",&n,&m)
#define sf3(n,m,s) scanf("%d %d %d",&n,&m,&s)
#define sfch(n) scanf("%c",&n)
#define sfl(n) scanf("%I64d",&n)
#define sfl2(n,m) scanf("%I64d %I64d",&n,&m)
#define sff(n) scanf("%lf",&n)
#define sfs(n) scanf("%s",n)
#define line(n) getline(cin,n)

#define INF (int)1e18
#define bitcount __builtin_popcount
#define fll(a,v) memset(a, v, sizeof a)
#define sz(a) ((int)(a.size()))
#define checkbit(n,b) ( (n >> b) & 1)

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector< vector<int> > adjl;
struct edge {
  ll from,to,w,c;
  edge (ll from,ll to,ll w):from(from),to(to),w(w) {}
  bool operator < (const edge & e) const {
      return ((w > e.w));
  }
};
typedef vector<vector<edge> > adjlw;
typedef vector<vector<long long>> Matrix;
ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}

void O_o()
{
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}

int main()
{
  O_o();
#ifndef ONLINE_JUDGE
  freopen("in.in", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  int n; cin >> n;
  int arr[n];
  input(arr, n);
  ll ans = 0;
  forn(i, n)
  {
    ll res = 0;
    fora(j,i,n) {
      res ^= arr[j];
      remax(ans, res);
    }
  }
  cout << ans << endl;

}


#include <bits/stdc++.h>
#include <algorithm>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 100000000

#define all(x) x.begin(),x.end()
#define sorta(x) sort(all(x))
#define sortr(x) sort(x.rbegin(),x.rend())
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define fora(i,a,b) for (int i=a;i<b;i++)
#define forit(v, c) for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define min(a, b) (((a)<(b))?(a):(b))
#define max(a, b) (((a)>(b))?(a):(b))
#define remax(a,b) (long long)(a)=max((a),(b))
#define remin(a,b) (long long)(a)=min((a),(b))
#define digits(i) (int)((log(i)/log(10))+1)
#define powof2(n) (!(n & (n-1)))
#define setbit(n,x) (n |= (1<<x))
#define test int t;cin>>t;while(t--)
#define input(a,n) for(int i = 0; i < n;i++)cin>>a[i];
#define valid(i,j,n,m) (bool)(i >= 0 && i < n && j >= 0 && j < m)
#define valid1(i,j,n,m) (bool)(i > 0 && i <= n && j > 0 && j <= m)

#define sf(n) scanf("%d",&n)
#define sf2(n,m) scanf("%d %d",&n,&m)
#define sf3(n,m,s) scanf("%d %d %d",&n,&m,&s)
#define sfch(n) scanf("%c",&n)
#define sfl(n) scanf("%I64d",&n)
#define sfl2(n,m) scanf("%I64d %I64d",&n,&m)
#define sff(n) scanf("%lf",&n)
#define sfs(n) scanf("%s",n)
#define line(n) getline(cin,n)

#define INF (int)1e18
#define bitcount __builtin_popcount
#define fll(a,v) memset(a, v, sizeof a)
#define sz(a) ((int)(a.size()))
#define checkbit(n,b) ( (n >> b) & 1)

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector< vector<int> > adjl;
struct edge {
  ll from,to,w,c;
  edge (ll from,ll to,ll w):from(from),to(to),w(w) {}
  bool operator < (const edge & e) const {
      return ((w > e.w));
  }
};
typedef vector<vector<edge> > adjlw;
typedef vector<vector<long long>> Matrix;
ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}

void O_o()
{
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}

int main()
{
  O_o();
#ifndef ONLINE_JUDGE
  freopen("in.in", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  int n; cin >> n;
  int arr[n];
  input(arr, n);
  ll ans = 0;
  forn(i, n)
  {
    forn(j, 8)
    {
      if(checkbit(arr[i], j))
        setbit(ans, j);
    }
  }
  cout << ans << endl;

}


#include <bits/stdc++.h>
#include <algorithm>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define mod 100000000

#define all(x) x.begin(),x.end()
#define sorta(x) sort(all(x))
#define sortr(x) sort(x.rbegin(),x.rend())
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define dwn(i,n) for(int i=(n); --i>=0; )
#define fora(i,a,b) for (int i=a;i<b;i++)
#define forit(v, c) for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define min(a, b) (((a)<(b))?(a):(b))
#define max(a, b) (((a)>(b))?(a):(b))
#define remax(a,b) (long long)(a)=max((a),(b))
#define remin(a,b) (long long)(a)=min((a),(b))
#define digits(i) (int)((log(i)/log(10))+1)
#define powof2(n) (!(n & (n-1)))
#define setbit(n,x) (n |= (1<<x))
#define test int t;cin>>t;while(t--)
#define input(a,n) for(int i = 0; i < n;i++)cin>>a[i];
#define valid(i,j,n,m) (bool)(i >= 0 && i < n && j >= 0 && j < m)
#define valid1(i,j,n,m) (bool)(i > 0 && i <= n && j > 0 && j <= m)

#define sf(n) scanf("%d",&n)
#define sf2(n,m) scanf("%d %d",&n,&m)
#define sf3(n,m,s) scanf("%d %d %d",&n,&m,&s)
#define sfch(n) scanf("%c",&n)
#define sfl(n) scanf("%I64d",&n)
#define sfl2(n,m) scanf("%I64d %I64d",&n,&m)
#define sff(n) scanf("%lf",&n)
#define sfs(n) scanf("%s",n)
#define line(n) getline(cin,n)

#define INF (int)1e18
#define bitcount __builtin_popcount
#define fll(a,v) memset(a, v, sizeof a)
#define sz(a) ((int)(a.size()))
#define checkbit(n,b) ( (n >> b) & 1)

using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector< vector<int> > adjl;
struct edge {
  ll from,to,w,c;
  edge (ll from,ll to,ll w):from(from),to(to),w(w) {}
  bool operator < (const edge & e) const {
      return ((w > e.w));
  }
};
typedef vector<vector<edge> > adjlw;
typedef vector<vector<long long>> Matrix;
ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}

void O_o()
{
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}

int main()
{
  O_o();
#ifndef ONLINE_JUDGE
  freopen("in.in", "r", stdin);
  //freopen("output.txt", "w", stdout);
#endif
  int n; cin >> n;
  int arr[n];
  input(arr, n);
  ll ans = 0;
  forn(i, n)
  {
    forn(j, 31)
    {
      if(checkbit(arr[i], j))
        setbit(ans, j);
    }
  }
  cout << ans << endl;

}


# include <iostream>
  using namespace std;
  long long arr[110];
  int main()
  {
      long long n, i, p, a, max_e;
      cin >> n;
      for(i = 1; i <= n; i++){
          cin >> arr[i];
      }
      max_e = -1;
      for(i = 1; i <= n; i++){
          p = 0;
          for(a = i; a <= n; a++){
              p = p | arr[a];
              if(p > max_e) max_e = p;
          }
      }
      cout << max_e;
      return 0;
  }


# include <iostream>
  using namespace std;
  long long arr[10010];
  int main()
  {
      long long n, i, p, a, max_e;
      cin >> n;
      for(i = 1; i <= n; i++){
          cin >> arr[i];
      }
      max_e = arr[1];
      for(i = 1; i <= n; i++){
          p = arr[i];
          if(p > max_e) max_e = p;
          for(a = i + 1; a <= n; a++){
              p = p ^ arr[a];
              if(p > max_e) max_e = p;
          }
      }
      cout << max_e;
      return 0;
  }


# include <iostream>
  using namespace std;
  long long arr[10010];
  int main()
  {
      long long n, i, p, a, max_e;
      cin >> n;
      for(i = 1; i <= n; i++){
          cin >> arr[i];
      }
      max_e = arr[1];
      for(i = 1; i <= n; i++){
          p = arr[i];
          if(p > max_e) max_e = p;
          for(a = i + 1; a <= n; a++){
              p = p | arr[a];
              if(p > max_e) max_e = p;
          }
      }
      cout << max_e;
      return 0;
  }


# include <iostream>
  using namespace std;
  long long arr[110];
  int main()
  {
      long long n, i, p, a, max_e;
      cin >> n;
      for(i = 1; i <= n; i++){
          cin >> arr[i];
      }
      max_e = arr[1];
      for(i = 1; i <= n; i++){
          p = arr[i];
          if(p > max_e) max_e = p;
          for(a = i + 1; a <= n; a++){
              p = p | arr[a];
              if(p > max_e) max_e = p;
          }
      }
      cout << max_e;
      return 0;
  }


//Bismillah
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,begin,end) for (ll i=begin;i<=end;i++)
#define rep(i,t) for (ll i=0;i<t;i++)
#define pb push_back
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    int n,a[200];
    cin>>n;
    FOR(i,1,n)
        cin>>a[i];
    int res = -1;
    FOR(i,1,n)
        FOR(j,i,n)
        {
            int temp = a[i];
            FOR(k,i+1,j)
                temp = res^a[k];
            res = max(res,temp);
        }
    cout<<res<<endl;
    return 0;
}


//Bismillah
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,begin,end) for (ll i=begin;i<=end;i++)
#define rep(i,t) for (ll i=0;i<t;i++)
#define pb push_back
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,a[200];
    cin>>n;
    FOR(i,1,n)
        cin>>a[i];
    ll res = -1;
    FOR(i,1,n)
        FOR(j,i,n)
        {
            ll temp = a[i];
            FOR(k,i+1,j)
                temp = res^a[k];
            res = max(res,temp);
        }
    cout<<res<<endl;
    return 0;
}


//Bismillah
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,begin,end) for (ll i=begin;i<=end;i++)
#define rep(i,t) for (ll i=0;i<t;i++)
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    int n, a[100010];
    cin>>n;
    rep(i,n) cin>>a[i];
    int res = 0;
    rep(i,n)
    {
        FOR(j,i,n-1)
        {
            int temp = a[i];
            FOR(k,i+1,j)
                temp = temp^a[k];
            res = max(temp,res);
        }
    }
    cout<<res;
    return 0;
}


//Bismillah
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,begin,end) for (ll i=begin;i<=end;i++)
#define rep(i,t) for (ll i=0;i<t;i++)
#define pb push_back
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    ll n,a[200];
    cin>>n;
    FOR(i,1,n)
        cin>>a[i];
    ll res = -1;
    FOR(i,1,n)
        FOR(j,i,n-1)
        {
            ll temp = a[i];
            FOR(k,i+1,j)
                temp = res^a[k];
            res = max(res,temp);
        }
    cout<<res<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<math.h>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
int main ()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll mx=0,c;
    for(ll i=0;i<n;i++)
    {
        if(a[i]>mx) mx=a[i];
    }
    for(ll i=0;i<n-1;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
           c=a[i]^a[j];
           mx=max(c,mx);

        }
    }
    cout<<mx<<endl;

    return 0;

}


#include<iostream>
#include<cstdio>
#include<vector>
#include<math.h>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
int main ()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll mx=0,c;
    for(ll i=0;i<n;i++)
    {
        if(a[i]>mx) mx=a[i];
    }
    for(ll i=0;i<n-1;i++)
    {
        c=0;
        for(ll j=i+1;j<n;j++)
        {
           c=c^a[j];
           mx=max(c,mx);
           //cout<<c<<' ';

        }
        cout<<mx<<endl;
    }
    cout<<mx<<endl;

    return 0;

}


#include<iostream>
#include<cstdio>
#include<vector>
#include<math.h>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
int main ()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll mx=0,c;
    for(ll i=0;i<n;i++)
    {
        if(a[i]>mx) mx=a[i];
    }
    for(ll i=0;i<n-1;i++)
    {
        c=0;
        for(ll j=i+1;j<n;j++)
        {
           c=c^a[j];
           mx=max(c,mx);
           //cout<<c<<' ';

        }
        //cout<<mx<<endl;
    }
    cout<<mx<<endl;

    return 0;

}


#include<iostream>
#include<cstdio>
#include<vector>
#include<math.h>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
int main ()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll mx=0,c;
    if(n==1) {cout<<a[0]; return 0;}
    for(ll i=0;i<n-1;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
           c=a[i]^a[j];
           mx=max(c,mx);

        }
    }
    cout<<mx<<endl;

    return 0;

}


#include<iostream>
#include<cstdio>
#include<vector>
#include<math.h>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
int main ()
{
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++) cin>>a[i];
    ll mx=0,c;
    for(ll i=0;i<n;i++)
    {
        if(a[i]>mx) mx=a[i];
    }
    for(ll i=0;i<n;i++)
    {
        c=0;
        for(ll j=i;j<n;j++)
        {
           c=c^a[j];
           mx=max(c,mx);
           //cout<<c<<' ';

        }
        //cout<<mx<<endl;
    }
    cout<<mx<<endl;

    return 0;

}


/*
*  In the name of God
*
*  Author: Farbod Doost
*  Date: Wednesday, 9 September, 2020 (9/9/2020)
*
*/
#include <iostream>
#include <limits.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    int a[n];
    for(size_t i = 0; i < n; i++)
        cin >> a[i];

    int ans = INT_MIN;
    for(size_t i = 0; i < n; i++)
        for(size_t j = i; j < n; j++){
            int test = 0;
            for(size_t k = i; k <= j; k++)
                test ^= k;

            if(test > ans)
                ans = test;
        }

    cout << ans;

    return 0;
}


/*
*  In the name of God
*
*  Author: Farbod Doost
*  Date: Wednesday, 9 September, 2020 (9/9/2020)
*
*/
#include <iostream>
#include <limits.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    int a[n];
    for(size_t i = 0; i < n; i++)
        cin >> a[i];

    int ans = INT_MIN;
    for(size_t i = 0; i < n; i++)
        for(size_t j = i + 1; j < n; j++){
            int test = 0;
            for(size_t k = i; k <= j; k++)
                test ^= k;

            if(test > ans)
                ans = test;
        }

    cout << ans;

    return 0;
}


/*
*  In the name of God
*
*  Author: Farbod Doost
*  Date: Wednesday, 9 September, 2020 (9/9/2020)
*
*/
#include <iostream>
#include <limits.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    int a[n];
    for(size_t i = 0; i < n; i++)
        cin >> a[i];

    int ans = INT_MIN;
    for(size_t i = 0; i < n; i++)
        for(size_t j = i; j < n; j++){
            int test = 0;
            for(size_t k = i; k <= j; k++)
                test ^= a[k];

            if(test > ans)
                ans = test;
        }

    cout << ans;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
ll mod = 1000000007;
#define speed      ios::sync_with_stdio(false)
#define rng(i,a,b) for (int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define cler(x,a)  memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define pb(x)      push_back(x)
#define sz(x)      (x.size())
#define f first
#define s second
#define sc(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
*/
const int m = 123;
int n;
int  a[m];
int ans=0,tmp;
int main()
{
    speed;
    sc(n);rep(i,1,n) sc(a[i]);
    rep(i,1,n){
        tmp=0;
        rep(j,i,n){
        tmp^=a[j];
        ans=max(ans,tmp);
        }
    }
    return cout<<ans,0;
}
/*
 fflush(stdout);
 cout.flush();
    ll A,B,n,x;
    scanf("%I64d%I64d%I64d%I64d",&A,&B,&n,&x);
    if(A==1)printf("%I64d",(x+n%MOD*B)%MOD);
    else
    {
        ll res=fp(A,n)*x%MOD;
        res+=(fp(A,n)-1)*fp(A-1,MOD-2)%MOD*B;
        printf("%I64d",(res%MOD+MOD)%MOD);
    }

bool cmp(string x,string y)   {return x+y<y+x;}
int dx[]= {0,0 ,1,-1, 1,1,-1,-1};
int dy[]= {1,-1,0,0 , 1,-1,1,-1};
bool inside (int i,int j) {return (i>=1 && i<=n && j>=1 && j<=m);}

ll pw(ll a,ll k){
ll res=1;a%=MOD;while(k){if(k&1)res=res*a%MOD;a=a*a%MOD;k>>=1;}
return res;}

bool prime[100007];
void sieve()
{
    for(int i=4; i<=100005; i+=2)
        prime[i]=false,prime[i-1]=true;
    prime[2]=true;
    for(int i=3; i<=1000; i+=2)
    {
        if(prime[i])
        {
            for(int j=i*i; j<=100005; j+=i*2)
                prime[j]=false;

        }

    }

}

    ll a,b,n,x,na,nb;
    cin>>a>>b>>n>>x;
    while(n){
        if (n&1){
            x=(a*x+b)%MOD;
        }
        n>>=1;
        na=a*a%MOD;
        nb=(a*b+b)%MOD;
        a=na;
        b=nb;
    }
    cout<<x;
*/


#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
ll mod = 1000000007;
#define speed      ios::sync_with_stdio(false)
#define rng(i,a,b) for (int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define cler(x,a)  memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define pb(x)      push_back(x)
#define sz(x)      (x.size())
#define f first
#define s second
#define sc(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
/*
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
*/
const int m = 100;
int n;
ll a[m];
ll ans=0LL,tmp;
int main()
{
    speed;
    sc(n);rep(i,1,n) sc(a[i]);
    rep(i,1,n){
        tmp=0LL;
        rep(j,i,n){
        tmp^=a[j];
        ans=max(ans,tmp);
        }
    }
    return cout<<ans,0;
}
/*
 fflush(stdout);
 cout.flush();
    ll A,B,n,x;
    scanf("%I64d%I64d%I64d%I64d",&A,&B,&n,&x);
    if(A==1)printf("%I64d",(x+n%MOD*B)%MOD);
    else
    {
        ll res=fp(A,n)*x%MOD;
        res+=(fp(A,n)-1)*fp(A-1,MOD-2)%MOD*B;
        printf("%I64d",(res%MOD+MOD)%MOD);
    }

bool cmp(string x,string y)   {return x+y<y+x;}
int dx[]= {0,0 ,1,-1, 1,1,-1,-1};
int dy[]= {1,-1,0,0 , 1,-1,1,-1};
bool inside (int i,int j) {return (i>=1 && i<=n && j>=1 && j<=m);}

ll pw(ll a,ll k){
ll res=1;a%=MOD;while(k){if(k&1)res=res*a%MOD;a=a*a%MOD;k>>=1;}
return res;}

bool prime[100007];
void sieve()
{
    for(int i=4; i<=100005; i+=2)
        prime[i]=false,prime[i-1]=true;
    prime[2]=true;
    for(int i=3; i<=1000; i+=2)
    {
        if(prime[i])
        {
            for(int j=i*i; j<=100005; j+=i*2)
                prime[j]=false;

        }

    }

}

    ll a,b,n,x,na,nb;
    cin>>a>>b>>n>>x;
    while(n){
        if (n&1){
            x=(a*x+b)%MOD;
        }
        n>>=1;
        na=a*a%MOD;
        nb=(a*b+b)%MOD;
        a=na;
        b=nb;
    }
    cout<<x;
*/


#include<bits/stdc++.h>
#define TP __int128
#define Max 109
using namespace std;
inline TP read(){
    char c=getchar();
    TP x=0;
    bool f=0;
    while(!isdigit(c))f^=!(c^45),c=getchar();
    while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f)x=-x;return x;
}
inline double readdouble(){
    char c=getchar();
    double x=0;
    bool f=0;
    while(!isdigit(c))f^=!(c^45),c=getchar();
    while(isdigit(c))x=x*10+(c^48),c=getchar();
    if(!(c^46)){
        double t=1;c=getchar();
        while(isdigit(c))t/=10,x+=t*(c^48),c=getchar();
    }if(f)x=-x;return x;
}
inline bool blank(char c){return !(c&&c^9&&c^10&&c^13&&c^32);}
inline void readstr(char *s){
    char c=getchar();
    while(blank(c))c=getchar();
    while(!blank(c))*s++=c,c=getchar();*s=0;
}
inline bool isendl(char c){return !(c&&c^10&&c^13);}
inline void getstr(char *s){
    char c=getchar();
    while(isendl(c))c=getchar();
    while(!isendl(c))*s++=c,c=getchar();*s=0;
}
int n,a[Max],b[Max];
int main(){
    n=read();
    for(int i=1;i<=n;++i){
    	a[i]=read();
		b[i]=(b[i-1]^a[i]);
    }
    int ans=0;
    for(int i=1;i<=n;++i){
        for(int j=i;j<=n;++j){
            ans=max(ans,b[j]^b[i-1]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


#include<bits/stdc++.h>
#define TP __int128
#define Max 109
using namespace std;
inline TP read(){
    char c=getchar();
    TP x=0;
    bool f=0;
    while(!isdigit(c))f^=!(c^45),c=getchar();
    while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f)x=-x;return x;
}
int n,a[Max],b[Max];
int main(){
    n=read();
    for(int i=1;i<=n;++i){
    	a[i]=read();
		b[i]=(b[i-1]^a[i]);
    }
    int ans=0;
    for(int i=1;i<=n;++i){
        for(int j=i;j<=n;++j){
            ans=max(ans,b[j]^b[i-1]);
        }
    }
    printf("%d\n",ans);
    return 0;
}