Tanya wants to go on a journey across the cities of Berland. There are $n$ cities situated along the main railroad line of Berland, and these cities are numbered from $1$ to $n$.

Tanya plans her journey as follows. First of all, she will choose some city $c_1$ to start her journey. She will visit it, and after that go to some other city $c_2 > c_1$, then to some other city $c_3 > c_2$, and so on, until she chooses to end her journey in some city $c_k > c_{k - 1}$. So, the sequence of visited cities $[c_1, c_2, \dots, c_k]$ should be strictly increasing.

There are some additional constraints on the sequence of cities Tanya visits. Each city $i$ has a beauty value $b_i$ associated with it. If there is only one city in Tanya's journey, these beauty values imply no additional constraints. But if there are multiple cities in the sequence, then for any pair of adjacent cities $c_i$ and $c_{i + 1}$, the condition $c_{i + 1} - c_i = b_{c_{i + 1}} - b_{c_i}$ must hold.

For example, if $n = 8$ and $b = [3, 4, 4, 6, 6, 7, 8, 9]$, there are several three possible ways to plan a journey:

$c = [1, 2, 4]$;

$c = [3, 5, 6, 8]$;

$c = [7]$ (a journey consisting of one city is also valid).

There are some additional ways to plan a journey that are not listed above.

Tanya wants her journey to be as beautiful as possible. The beauty value of the whole journey is the sum of beauty values over all visited cities. Can you help her to choose the optimal plan, that is, to maximize the beauty value of the journey?


-----Input-----

The first line contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of cities in Berland.

The second line contains $n$ integers $b_1$, $b_2$, ..., $b_n$ ($1 \le b_i \le 4 \cdot 10^5$), where $b_i$ is the beauty value of the $i$-th city.


-----Output-----

Print one integer — the maximum beauty of a journey Tanya can choose.


-----Examples-----

Input
6
10 7 1 9 10 15
Output
26
Input
1
400000
Output
400000
Input
7
8 9 26 11 12 29 14
Output
55


-----Note-----

The optimal journey plan in the first example is $c = [2, 4, 5]$.

The optimal journey plan in the second example is $c = [1]$.

The optimal journey plan in the third example is $c = [3, 6]$.

Difficulty: MEDIUM

Solutions:
import sys
input = sys.stdin.readline
from collections import defaultdict

def main():
	n = int(input())
	b = list(map(int, input().split()))
	m = 0
	g = defaultdict(int)
	for i in range(n):
		g[b[i] - i] += b[i]
		m = max(m, g[b[i] - i])
	print(m)
main()


n = int(input())
l = list(map(int, input().split()))
b = list(l)
dic = {}
for i in range(len(l)):
	l[i] -= i
	dic[l[i]] = []
for i in range(len(l)):
	dic[l[i]].append(b[i])
ans = -1
for i in dic.keys():
	ch = sum(dic[i])
	if ans < ch:
		ans = ch
print(ans)


input()
Essi = {}
ind = 1
for a in map(int, input().split()):
	Essi[a - ind] = Essi.get(a - ind, 0) + a
	ind += 1
print(max(Essi.values()))


n = int(input())
a = list(map(int, input().split()))
b = {}
c = 0
max_now = 0
for i in range(n):
	t = a[i] - i - 1
	if t not in b:
		b[t] = a[i]
	else:
		b[t] += a[i]
	if b[t] > max_now:
		max_now = b[t]
print(max_now)


n = int(input())
a = list(map(int, input().split()))
b = []
d = dict()
for i in range(len(a)):
	if i + 1 - a[i] not in d:
		d[i + 1 - a[i]] = 0
	d[i + 1 - a[i]] += a[i]
mx = 0
for i in d:
	mx = max(mx, d[i])
print(mx)


n = int(input())
lst = [int(i) for i in input().split()]
m = 0
dict = {}
type(dict)
for i in range(len(lst)):
	k = lst[i]
	dict[k - i] = 0
for i in range(len(lst)):
	k = lst[i]
	dict[k - i] = dict[k - i] + k
	m = max(dict[k - i], m)
print(m)


n = int(input())
l = list(map(int, input().split()))
c = {}
a = 0
for i in range(n):
	value = l[i] - i
	if c.get(str(value)):
		c[str(value)] += l[i]
	else:
		c[str(value)] = l[i]
for i in c:
	a = max(a, c[i])
print(a)


n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	v = i - a[i]
	if d.get(v) == None:
		d[v] = a[i]
	else:
		d[v] += a[i]
print(max(d.values()))


n = int(input())
l = list(map(int, input().split()))
dic = dict()
for i in range(n):
	a = l[i] - i
	b = l[i]
	if a in dic:
		dic[a] += b
	else:
		dic[a] = b
print(max(dic.values()))


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
n = int(input())
b = list(map(int, input().split()))
if n == 1:
	print(b[0])
else:
	d = {}
	for j in range(n):
		s = d.setdefault(j + 1 - b[j], 0)
		d[j + 1 - b[j]] += b[j]
	print(max(d.values()))


n = int(input())
b = [int(i) for i in input().split()]
h = {b[0]: 0}
dp = [b[i] for i in range(n)]
for i in range(1, n):
	x = b[i] - i
	if x in h:
		j = h[x]
		dp[i] = max(dp[i], b[i] + dp[j])
	h[x] = i
print(max(dp))


n = int(input())
b = [i for i in map(int, input().split())]
vis = [0 for i in range(600010)]
for i in range(n):
	vis[b[i] - i] = vis[b[i] - i] + b[i]
print(max(vis))


n = int(input())
arr = list(map(int, input().split()))
dp = {}
for i in range(n):
	x = arr[i] - i
	if x in dp:
		dp[x].append(arr[i])
	else:
		dp[x] = [arr[i]]
m = -100
for i in dp:
	m = max(sum(dp[i]), m)
print(m)


input()
l = list(map(int, input().split()))
d = {}
i = 1
for x in l:
	d[x - i] = d.get(x - i, 0) + x
	i += 1
print(max(d.values()))


n = int(input())
nums = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(set)
for i in range(len(nums)):
	d[i + 1 - nums[i]].add(nums[i])
print(sum(max(d.values(), key=lambda x: sum(x))))


n = int(input())
a = input().split()
a = [int(x) for x in a]
a = [a[i] - i for i in range(n)]
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = 0
	d[a[i]] += a[i] + i
m = 0
for k in d:
	m = max(m, d[k])
print(m)


n = int(input())
a = [int(i) for i in input().split()]
d = dict()
for i in range(n):
	s = a[i] - i
	d[s] = d.get(s, 0) + a[i]
print(max(list(d.values())))


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
from math import gcd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
d = dd(list)
n = inp(1)
l = inp()
for i in range(n):
	x = l[i] - i
	d[x].append(l[i])
ans = 0
for k in d:
	ans = max(ans, sum(d[k]))
print(ans)


n = int(input())
b = list(map(int, input().split()))
c = []
for i in range(n):
	c.append(b[i] - i)
d = {}
for i in range(n):
	if c[i] in d:
		d[c[i]] += b[i]
	else:
		d[c[i]] = b[i]
print(max(d.values()))


def JourneyPlanning(n, b):
	dp = [0] * 10 ** 6
	for i in range(n):
		a = b[i] - i
		dp[a] = dp[a] + b[i]
	return max(dp)
	if n == 1:
		return b[0]
	if n == 200000:
		return 60000100000
	dp = [[[]]]
	globalmax = b[0]
	dp[0][0] = b[0]
	for i in range(1, n):
		dp.append([])
		for j in range(i + 1):
			dp[i].append([])
			if i == j:
				dp[i][j] = dp[i][j - 1]
			elif i - j == b[i] - b[j]:
				dp[i][j] = dp[j][j] + b[i]
			elif j == 0:
				dp[i][j] = b[i]
			else:
				dp[i][j] = dp[i][j - 1]
			if globalmax < dp[i][j]:
				globalmax = dp[i][j]
	return globalmax
n = int(input())
a = list(map(int, input().rstrip().split()))
ans = JourneyPlanning(n, a)
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
d = {}
for i in range(n):
	if i - l[i] in d:
		d[i - l[i]] += l[i]
	else:
		d[i - l[i]] = l[i]
print(max(d.values()))


n = int(input())
b = list(map(int, input().split()))
d = dict()
for i in range(n):
	a = i - b[i]
	d[a] = d.get(a, 0) + b[i]
ans = max(d.values())
print(ans)


from collections import defaultdict
n = int(input())
b = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
	d[b[i] - i - 1] += b[i]
print(max(d.values()))


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
x = defaultdict(list)
for i in range(0, n):
	v = a[i] - i
	x[v].append(a[i])
m = 0
for i in x:
	if sum(x[i]) > m:
		m = sum(x[i])
print(m)


n = int(input())
x = list(map(int, input().split()))
c = 0
d = {}
for i in range(n):
	if x[i] - i in d:
		d[x[i] - i] += x[i]
	else:
		d[x[i] - i] = x[i]
for i in d:
	c = max(c, d[i])
print(c)


import sys
a = int(input())
b = list(map(int, input().split()))
if a == 1:
	print(b[0])
	sys.exit()
c = [0] * a
for i in range(a):
	c[i] = (b[i] - i - 1, b[i])
ans = 0
c.sort()
maxx = c[0][1]
cc = c[0][0]
i = 1
while i < a:
	while i < a and c[i][0] == cc:
		maxx += c[i][1]
		i += 1
	ans = max(ans, maxx)
	maxx = 0
	if i < a:
		cc = c[i][0]
print(ans)


R = lambda : [int(x) for x in input().split()]
[n] = R()
a = R()
dic = {}
for i in range(n):
	if i - a[i] in dic:
		dic[i - a[i]] += a[i]
	else:
		dic[i - a[i]] = a[i]
print(max(dic.values()))


n = int(input())
b = [int(x) for x in input().split(' ')]
output = [0] * 800000
for i in range(n):
	output[b[i] - (i + 1)] += b[i]
print(max(output))


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
n = int(input())
values = [*map(int, input().split())]
ans = dd(int)
for (i, x) in enumerate(values):
	ans[x - i] += x
print(max(ans.values()))


import sys
from collections import defaultdict
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
n = int(input())
b = list(map(int, input().split()))
shift = defaultdict(int)
for (i, val) in enumerate(b):
	shift[val - i] += val
ans = max(shift.values())
print(ans)


from sys import stdin, stdout
n = int(stdin.readline().strip())
b = list(map(int, stdin.readline().strip().split(' ')))
d = {}
for i in range(len(b)):
	key = b[i] - i
	if key in d:
		d[key].append(b[i])
	else:
		d[key] = [b[i]]
ans = -1
for i in d:
	ans = max(ans, sum(d[i]))
stdout.write(str(ans) + '\n')


from math import *
from sys import stdin
input = stdin.readline
(n, i) = (int(input()), 0)
d = {}
for x in list(map(int, input().split())):
	d[x - i] = d.get(x - i, 0) + x
	i += 1
print(max(d.values()))


import collections
n = int(input())
b = [int(x) for x in input().split()]
scores = collections.defaultdict(int)
for (x, y) in enumerate(b, start=1):
	scores[y - x] += y
print(max(scores.values()))


n = int(input())
lis = list(map(int, input().split()))
d = {}
for i in range(n):
	v = lis[i] - i
	if d.get(v):
		d[v] += lis[i]
	else:
		d[v] = lis[i]
m = 0
for k in d.values():
	m = max(m, k)
print(m)


n = int(input())
arr = [int(x) for x in input().split()]
map = {}
for (i, x) in enumerate(arr):
	idx = x - (i + 1)
	if idx in map:
		map[idx] += x
	else:
		map[idx] = x
print(max(map.values()))


n = int(input())
p = [*map(int, input().split())]
d = {}
i = 0
for x in p:
	d[x - i] = d.get(x - i, 0) + x
	i += 1
print(max(d.values()))


from collections import defaultdict

def solve(b):
	deltas = defaultdict(lambda : 0)
	for (i, k) in enumerate(b, 1):
		deltas[k - i] += k
	return max(deltas.values())
n = int(input())
b = [int(s) for s in input().split(' ')]
print(solve(b))


def solve(n, a):
	d = {}
	for i in range(n):
		diffs = a[i] - i
		d[diffs] = d.get(diffs, 0) + a[i]
	return max(d.values())
n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


def main():
	n = int(input())
	b = list(map(int, input().split()))
	c = b[:]
	for i in range(n):
		c[i] -= i
		b[i] = [b[i], c[i]]
	b.sort(key=lambda x: x[1])
	max_count = 0
	for i in range(n):
		if i == 0:
			a = b[i][1]
			count = b[i][0]
			max_count = count
		elif a == b[i][1]:
			count += b[i][0]
			max_count = max(max_count, count)
		elif a != b[i][1]:
			a = b[i][1]
			max_count = max(max_count, count)
			count = b[i][0]
			max_count = max(max_count, count)
	print(max_count)
main()


from sys import stdin
input = stdin.readline
n = int(input())
l = list(map(int, input().split()))
adj = [l[i] - i for i in range(n)]
ind_odp = []
d = {}
for i in range(n):
	d[adj[i]] = []
for i in range(n):
	d[adj[i]].append(i)
odp = 0
for elt in d:
	cyk = len(d[elt]) * elt
	for i in d[elt]:
		cyk += i
	odp = max(cyk, odp)
print(odp)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
b = I()
common_dist = dict()
for i in range(n):
	dist = b[i] - i
	if dist in common_dist:
		common_dist[dist].append(i)
	else:
		common_dist[dist] = [i]
max_but = 0
for key in common_dist:
	vals = common_dist[key]
	but = 0
	for val in vals:
		but += b[val]
	if but > max_but:
		max_but = but
print(max_but)


import os
import io
from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce
from collections import deque
import threading

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
n = iinput()
a = rlinput()
d = defaultdict(list)
mxtill = defaultdict(int)
ans = []
for i in range(n):
	mxtill[a[i] - i - 1] = 0
	ans.append(a[i])
for i in range(1, n + 1):
	if a[i - 1] - i in mxtill:
		ans[i - 1] += mxtill[a[i - 1] - i]
		mxtill[a[i - 1] - i] = max(ans[i - 1], mxtill[a[i - 1] - i])
print(max(ans))


from collections import defaultdict
n = int(input())
m = input()
l = [int(i) for i in m.split()]
x = defaultdict(list)
y = []
if len(m) == 1:
	print(m[0])
	exit(0)
for i in range(len(l)):
	x[l[i] - i].append(l[i])
for (key, value) in x.items():
	total = sum(value)
	y.append(total)
print(max(y))


from collections import defaultdict
N = int(input())
B = list(map(int, input().split()))
route = defaultdict(int)
for (i, beauty) in enumerate(B):
	route[beauty - i] += beauty
print(max(route.values()))


n = int(input())
a = list(map(int, input().split()))
dct = {}
for i in range(n):
	if a[i] - i in dct:
		dct[a[i] - i] += a[i]
	else:
		dct[a[i] - i] = a[i]
print(max(dct.values()))


from os import path
from sys import stdin, stdout
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')

def io():
	return stdin.readline()
maxn = 100005
ans = 0
n = int(io())
a = list(map(int, io().split()))
b = []
for i in range(n):
	b.append((a[i] - i - 1, a[i]))
b.sort()
cnt = 0
if n == 1:
	ans = a[0]
else:
	for i in range(1, n):
		if b[i][0] == b[i - 1][0]:
			cnt += b[i - 1][1]
		else:
			cnt += b[i - 1][1]
			ans = max(ans, cnt)
			cnt = 0
	cnt += b[n - 1][1]
	ans = max(ans, cnt)
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
b = [0] * n
c = [0] * 800020
for x in range(n):
	b[x] = a[x] - x + 400010
for x in range(n):
	c[b[x]] += a[x]
print(max(c))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
arr = rr()
ans = defaultdict(lambda : 0)
for i in range(n):
	ans[arr[i] - i] += arr[i]
print(max(ans.values()))


n = int(input())
arr = list(map(int, input().split()))
ar = []
for i in arr:
	ar.append(i)
for i in range(n):
	arr[i] -= i + 1
dic = {}
for i in arr:
	dic[i] = 0
ans = -float('inf')
for i in range(n):
	dic[arr[i]] += ar[i]
	ans = max(ans, dic[arr[i]])
print(ans)


n = int(input())
c = [int(__) for __ in input().split()]
b = c[:]
for i in range(len(b)):
	b[i] -= i
min_ = min(b)
for i in range(len(b)):
	b[i] -= min_
l1 = [0 for ___ in range(max(b) + 1)]
for i in range(len(b)):
	l1[b[i]] += c[i]
print(max(l1))


n = int(input())
bVar = [int(i) for i in str(input()).split()]
dp = [0 for i in range(n)]
con = 4 * 100000
diffArray = {}
maxValue = -1
for i in range(n):
	if i == 0:
		dp[i] = bVar[0]
		maxValue = max(maxValue, dp[i])
		diff = i + 1 - bVar[i]
		diffArray[diff] = [i]
		continue
	diff = i + 1 - bVar[i]
	boolCon = diff in diffArray
	if boolCon == False:
		dp[i] = bVar[i]
		maxValue = max(maxValue, dp[i])
		diffArray[diff] = [i]
	else:
		l = len(diffArray[diff])
		dp[i] = max(bVar[i], bVar[i] + dp[diffArray[diff][l - 1]])
		maxValue = max(maxValue, dp[i])
		diffArray[diff].append(i)
print(maxValue)


n = int(input())
b = list(map(int, input().split()))
dic = {}
for i in range(n):
	d = b[i] - i
	if dic.get(d) is None:
		dic[d] = b[i]
	else:
		dic[d] += b[i]
res = 0
for k in dic.keys():
	res = max(res, dic[k])
print(res)


def solve(n, a):
	d = {}
	ans = -1
	for (i, v) in enumerate(a):
		x = v - i
		if x in d:
			d[x] += v
		else:
			d[x] = v
		ans = max(ans, d[x])
	print(ans)

def main():
	inp = lambda : [int(x) for x in input().split()]
	n = int(input())
	a = inp()
	solve(n, a)
main()


n = int(input())
a = list(map(int, input().split()))
ans = 0
b = [0] * 1000000
for i in range(0, n):
	b[a[i] - i - 1] = b[a[i] - i - 1] + a[i]
for i in range(0, n):
	ans = max(ans, b[a[i] - i - 1])
print(ans)


n = int(input())
r = [int(x) for x in input().split()]
t = [0 for i in range(600002)]
for i in range(n):
	t[199999 + r[i] - i] += r[i]
print(max(t))


n = int(input())
arr = list(map(int, input().split()))
dict = {}
maxi = 0
for i in range(len(arr)):
	try:
		temp = dict[i - arr[i]]
		dict[i - arr[i]] = temp + arr[i]
		if maxi < temp + arr[i]:
			maxi = temp + arr[i]
	except:
		dict[i - arr[i]] = arr[i]
		if maxi < arr[i]:
			maxi = arr[i]
print(maxi)


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
	d[a[i] - i] += a[i]
max = 0
for val in d.values():
	if val > max:
		max = val
print(max)


n = int(input())
arr = list(map(int, input().split()))
lis = [0] * 10 ** 6
for i in range(n):
	v = arr[i] - i
	lis[v] += arr[i]
print(max(lis))


import sys
from collections import defaultdict
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
dic = defaultdict(list)
for i in range(n):
	dic[arr[i] - i].append(arr[i])
ans = 0
for i in dic:
	if sum(dic[i]) > ans:
		ans = sum(dic[i])
print(ans)


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
n = INI()
X = INL()
D = dict()
ans = float('-inf')
for _ in range(n):
	D[X[_] - _] = D.get(X[_] - _, 0) + X[_]
	ans = max(ans, D[X[_] - _])
OPS(ans)


n = int(input())
d = list(map(int, input().split()))[:n]
di = dict()
ans = 0
for (i, n) in enumerate(d):
	h = n - i
	if h not in di:
		di[h] = n
	else:
		di[h] += n
print(max(di.values()))


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	if l[i] - i in d:
		d[l[i] - i] += l[i]
	else:
		d[l[i] - i] = l[i]
print(max(d.values()))


n = int(input())
b = list(map(int, input().split()))
list1 = {}
val = []
for i in range(n):
	if i - b[i] in list1:
		list1[i - b[i]] += b[i]
	else:
		list1[i - b[i]] = b[i]
print(max(list1.values()))


n = int(input())
beauty = list(map(int, input().split()))
m = max(beauty)
l = [0] * n
for i in range(len(beauty)):
	l[i] = -i + beauty[i]
d = {}
for i in range(len(l)):
	if str(l[i]) in d.keys():
		d[str(l[i])] += beauty[i]
	else:
		d[str(l[i])] = beauty[i]
print(max(d.values()))


t = int(input())
a = list(map(int, input().split()))
dic = {}
for i in range(t):
	b = a[i] - (i + 1)
	if b in dic.keys():
		dic[b] += a[i]
	else:
		dic[b] = a[i]
print(max(dic.values()))


from collections import defaultdict
n = int(input())
b = [int(x) for x in input().split()]
d = defaultdict(int)
for i in range(len(b)):
	d[b[i] - i] += b[i]
print(max(d.values()))


n = int(input())
bs = list(map(int, input().split(' ')))
mp = {}
for i in range(n):
	k = bs[i] - i
	if k not in mp.keys():
		mp[k] = bs[i]
	else:
		mp[k] += bs[i]
ans = max(mp.values())
print(ans)


n = int(input())
ls = [int(a) for a in input().split()]
ls1 = []
kvp = dict()
for i in range(n):
	k = ls[i] - i
	ls1.append(k)
	if ls1[i] not in kvp:
		kvp[ls1[i]] = ls[i]
	else:
		kvp[ls1[i]] += ls[i]
print(max(kvp.values()))


from collections import Counter
n = int(input())
B = list(map(int, input().split()))
K = [B[i] - (i + 1) for i in range(n)]
bestK = Counter()
for i in range(n - 1, -1, -1):
	bestK[K[i]] = bestK[K[i]] + B[i]
print(max(bestK.values()))


n = int(input())
a = list(map(int, input().split()))
mp = {}
for i in range(n):
	cur = a[i] - i
	if cur in mp:
		mp[cur] += a[i]
	else:
		mp[cur] = a[i]
ans = 0
for el in mp:
	ans = max(ans, mp[el])
print(ans)


from collections import *
(n, a, mem) = (int(input()), list(map(int, input().split())), defaultdict(int))
for i in range(n):
	mem[a[i] - i] += a[i]
print(max(mem.values()))


from sys import stdin, stdout, setrecursionlimit

class Tail_Recursion_Optimization:

	def __init__(self, RECURSION_LIMIT, STACK_SIZE):
		setrecursionlimit(RECURSION_LIMIT)
		threading.stack_size(STACK_SIZE)
		return None

class SOLVE:

	def solve(self):
		R = stdin.readline
		W = stdout.write
		n = int(R())
		b = [int(x) for x in R().split()]
		(check, mx) = ({}, 0)
		for i in range(n):
			tmp = b[i] - i
			if tmp not in check:
				check[tmp] = b[i]
			else:
				check[tmp] += b[i]
			mx = max(mx, check[tmp])
		W('%d\n' % mx)
		return 0

def main():
	s = SOLVE()
	s.solve()
main()


import math
n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	try:
		d[l[i] - i] += l[i]
	except:
		d[l[i] - i] = l[i]
print(max(d.values()))


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
diff = a[:]
for i in range(1, n + 1):
	diff[i - 1] -= i
d = defaultdict(int)
for (i, v) in enumerate(diff):
	d[v] += a[i]
print(max(d.values()))


n = int(input())
entrada = [int(i) for i in input().split(' ')]
m = [0] * int(1000000.0)
mx = 0
for p in range(n):
	b = entrada[p]
	m[b - p] = m[b - p] + b
	if mx > m[b - p]:
		mx = mx
	else:
		mx = m[b - p]
print(mx)


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n,) = I()
b = I()
for i in range(n):
	b[i] = [b[i], i]
a = [0] * n
idx = dd(int)
ans = 0
for i in range(n):
	x = b[i][0] - b[i][1]
	idx[x] += b[i][0]
	ans = max(ans, idx[x])
print(ans)


from collections import defaultdict

def main():
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	max_cost = 0
	for i in range(n):
		d[a[i] - i] += a[i]
		max_cost = max(max_cost, d[a[i] - i])
	print(max_cost)
main()


n = input()
b = input().split()
b = [int(i) for i in b]
m = {}
for i in range(len(b)):
	if b[i] - i not in m:
		m[b[i] - i] = b[i]
	else:
		m[b[i] - i] += b[i]
mx = max(m.values())
print(mx)


n = int(input())
b = list(map(int, input().split()))
mem = {}
for i in range(n):
	if i - b[i] not in mem:
		mem[i - b[i]] = 0
	mem[i - b[i]] += b[i]
ans = 0
for i in mem:
	ans = max(ans, mem[i])
print(ans)


import sys
from collections import defaultdict
input = sys.stdin.readline
n = int(input())
lis = list(map(int, input().split()))
for i in range(n):
	lis[i] -= i
d = defaultdict(int)
for i in range(n):
	d[lis[i]] += i + lis[i]
print(max(d.values()))


from math import ceil
import sys
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
for i in range(n):
	b[i] = a[i] - i
d = dict()
for i in range(n):
	if b[i] not in d.keys():
		d[b[i]] = a[i]
	else:
		d[b[i]] += a[i]
print(max(d.values()))


n = int(input())
beauty = list(map(int, input().split()))
diff_values = {}
ans = []
for i in range(n):
	temp = beauty[i] - i
	try:
		t = diff_values[temp]
	except KeyError:
		diff_values[temp] = 0
	ans.append(temp)
max = 0
for i in range(n):
	diff_values[ans[i]] += beauty[i]
	if max < diff_values[ans[i]]:
		max = diff_values[ans[i]]
print(max)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
b = list(map(int, input().split()))
d = {}
for i in range(n):
	d[b[i] - i] = d.get(b[i] - i, 0) + b[i]
print(max(d.values()))


import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def solve(N, B):
	i = 0
	d = {}
	for x in B:
		d[x - i] = d.get(x - i, 0) + x
		i += 1
	return max(d.values())
N = int(input())
B = get_ints()
print(solve(N, B))


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	print(l[0])
	exit()
d = {}
for i in range(n):
	if l[i] - i not in d:
		d[l[i] - i] = [l[i]]
	else:
		d[l[i] - i].append(l[i])
ans = 0
for i in d:
	if sum(d[i]) > ans:
		ans = sum(d[i])
print(ans)


def solve(n, cities):
	ans = {}
	for index in range(n):
		if ans.get(index - cities[index]) != None:
			ans[index - cities[index]] += cities[index]
		else:
			ans[index - cities[index]] = cities[index]
	maximum = 0
	for v in ans.values():
		if v > maximum:
			maximum = v
	return maximum
n = int(input())
cities = list(map(int, input().split()))
print(solve(n, cities))


n = int(input())
a = list(map(int, input().split()))
x = []
dict1 = {}
for i in range(n):
	c = a[i] - i
	x.append(c)
	if dict1.get(str(c)):
		dict1[str(c)] += a[i]
	else:
		dict1[str(c)] = a[i]
max1 = 0
for i in dict1:
	max1 = max(max1, dict1[i])
print(max1)


import sys
n = int(input())
if 1 <= n <= 2 * 10 ** 5:
	lst = list(map(int, input().split()))
	if len(lst) < n:
		print('Enter all the input correctly.')
		sys.exit(1)
	g = {}
	for j in range(n):
		g[lst[j] - j] = g.get(lst[j] - j, 0) + lst[j]
	print(max(g.values()))
else:
	print('Invalid Input')


n = int(input())
beauty = list(map(int, input().split()))
norm_beauty = [b - i for (i, b) in enumerate(beauty)]
max_beuty = {}
m = 0
for (i, x) in enumerate(norm_beauty):
	if x in max_beuty:
		max_beuty[x] += beauty[i]
	else:
		max_beuty[x] = beauty[i]
	m = max(max_beuty[x], m)
print(m)


n = int(input())
b = list(map(int, input().split()))
s = dict()
for i in range(n):
	x = b[i] - i
	y = b[i]
	if x in s:
		s[x] += y
	else:
		s[x] = y
print(max(s.values()))


def main():
	input()
	numbers = list(map(int, input().split(' ')))
	a = []
	for (index, number) in enumerate(numbers):
		a.append(number - index - 1)
	b = {}
	for (index, number) in enumerate(a):
		if number in b:
			b[number] += numbers[index]
		else:
			b[number] = numbers[index]
	print(max(b.values()))
main()


n = int(input())
a = [int(i) for i in input().split()]
diff = [a[i] - (i + 1) for i in range(n)]
mem = {i: 0 for i in diff}
for i in range(n):
	mem[diff[i]] += a[i]
print(max(mem.values()))


class node:

	def __init__(self, index, beauty):
		self.index = index
		self.beauty = beauty
		self.dif = beauty - index

	def show(self):
		print('dif = ', self.dif)
n = int(input())
a = list(map(int, input().split()))
allnode = []
ans = [0] * 600003
offset = n
for i in range(0, n):
	allnode.append(node(i + 1, a[i]))
for i in range(10):
	ans.append(0)
for i in allnode:
	ans[offset + i.dif] = ans[offset + i.dif] + i.beauty
ans.sort()
print(ans[-1])


n = int(input())
arr = list(map(int, input().split()))
temp = []
dict = {}
for i in range(n):
	val = arr[i] - i
	if val not in dict.keys():
		dict[val] = arr[i]
	else:
		dict[val] += arr[i]
print(max(dict.values()))


import sys
input = sys.stdin.readline
from math import *
n = int(input())
a = [int(x) for x in input().split()]
maxi = max(a)
d = {}
for i in range(n):
	if a[i] - i in d:
		d[a[i] - i] += a[i]
	else:
		d[a[i] - i] = a[i]
for i in d:
	maxi = max(maxi, d[i])
print(maxi)


n = int(input())
used = [False] * n
b = [int(i) for i in input().split(' ')]
sum_arr = [0] * 1000000
for i in range(n):
	sum_arr[b[i] - i] += b[i]
ans = 0
for i in range(n):
	if sum_arr[b[i] - i] > ans:
		ans = sum_arr[b[i] - i]
print(ans)


n = int(input())
b = list(map(int, input().split()))
d = {}
j = 0
for i in range(n):
	d[b[i] - j] = d.get(b[i] - j, 0) + b[i]
	j += 1
print(max(d.values()))


n = int(input())
MX = 800010
cnt = []
for i in range(MX):
	cnt.append(0)
arr = input().split(' ')
for i in range(n):
	x = int(arr[i])
	y = x - i
	y = y + 400000
	cnt[y] += x
ans = 0
for i in range(MX):
	if cnt[i] > ans:
		ans = cnt[i]
print(ans)


n = int(input())
arr = [int(j) for j in input().split()]
for i in range(1, n + 1):
	arr[i - 1] = [arr[i - 1], arr[i - 1] - i]
freq = [0] * 1000000
for i in range(n):
	freq[arr[i][1]] += arr[i][0]
print(max(freq))


n = int(input())
a = [int(x) for x in input().split()]
b = [a[i] - i for i in range(n)]
d = {}
for i in range(n):
	if b[i] not in d.keys():
		d[b[i]] = a[i]
	else:
		d[b[i]] += a[i]
ans = float('-inf')
for key in d:
	ans = max(ans, d[key])
print(ans)


from collections import defaultdict
int(input())
b = [int(x) for x in input().split()]
c = [b[i] - i for i in range(len(b))]
d = defaultdict(list)
for (i, x) in enumerate(c):
	d[x].append(i)
ans = b[0]
for value in d:
	act = 0
	for i in d[value]:
		act += b[i]
	ans = max(ans, act)
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
b = [int(x) for x in input().split()]
c = [0] * 10 ** 6
for i in range(n):
	c[b[i] - i] += b[i]
print(max(c))


n = int(input())
a = list(map(int, input().split()))
d = {}
s = [0] * 4 * 10 ** 6
for i in range(n):
	s[a[i] - i] += a[i]
mx = 0
v = 0
print(max(s))


import math
n = int(input())
b = [int(x) for x in input().split()]
dict = {}
Max = 0
for i in range(n):
	c = b[i] - i
	if c in dict:
		dict[c] += b[i]
	else:
		dict[c] = b[i]
for i in dict:
	Max = max(Max, dict[i])
print(Max)


from collections import defaultdict
n = int(input())
b_list = [int(x) for x in input().split()]
c_list = [x for x in range(1, n + 1)]
d_list = [b_list[x - 1] - c_list[x - 1] for x in c_list]
a = defaultdict(list)
for (key, value) in zip(d_list, b_list):
	a[key].append(value)
sum_array = [sum(i) for i in a.values()]
print(max(sum_array))


n = int(input())
list_1 = list(map(int, input().split(' ')))
dic = {}
count = 0
for i in list_1:
	if i - count in dic:
		dic[i - count] += i
	else:
		dic.update({i - count: i})
	count += 1
ans = 0
for i in dic.values():
	ans = max(ans, i)
print(ans)


n = int(input())
b = [int(x) for x in input().split()]
dct = {}
for (i, k) in enumerate(b):
	v = i - k
	if v not in dct:
		dct[v] = [k]
	else:
		dct[v].append(k)
ans = 0
for i in dct:
	ans = max(ans, sum(dct[i]))
print(ans)


n = int(input())
arr = list(map(int, input().split()))
d = {}
for i in range(n):
	val = arr[i] - i
	if val not in d:
		d[val] = [arr[i]]
	else:
		d[val].append(arr[i])
m = -10 ** 10
ans = []
for i in d:
	m = max(m, sum(d[i]))
print(m)


import sys
import math
from math import *
from collections import defaultdict
import os
from io import BytesIO, IOBase
from collections import deque

def main():
	d = defaultdict(lambda : 0)
	n = int(input())
	arr = list(map(int, input().split()))
	res = []
	for i in range(n):
		arr[i] = arr[i] - i
	for i in range(n):
		d[arr[i]] += arr[i] + i
	mx = 0
	for (i, j) in d.items():
		mx = max(mx, j)
	print(mx)
main()


input()
a = {}
i = 0
for x in map(int, input().split()):
	a[x - i] = a.get(x - i, 0) + x
	i += 1
print(max(a.values()))


input()
ans = {}
i = 0
for x in input().strip().split():
	x = int(x)
	ans[i - x] = ans.get(i - x, 0) + x
	i += 1
print(max(ans.values()))


n = int(input())
k = 1
D = {}
M = set()
mx = 0
for i in input().split():
	i = int(i)
	r = i - k
	k += 1
	if r in M:
		D[r] += i
		mx = max(mx, D[r])
	else:
		M.add(r)
		D[r] = i
		mx = max(mx, D[r])
print(mx)


n = int(input())
a = [int(x) for x in input().split()]
f = {}
for i in range(n):
	x = a[i] - (i + 1)
	if x in f:
		f[x].append(a[i])
	else:
		f[x] = [a[i]]
x = 0
for m in f.keys():
	x = max(x, sum(f[m]))
print(x)


n = int(input())
m1 = {}
a = [int(x) for x in input().split()]
i = 0
while i < n:
	if a[i] - i in m1:
		m1[a[i] - i] += a[i]
	else:
		m1[a[i] - i] = a[i]
	i += 1
k = -1
for x in m1:
	k = max(k, m1[x])
print(k)


n = int(input())
arr = list(map(int, input().split()))
temp = {}
for i in range(n):
	if i - arr[i] in temp:
		temp[i - arr[i]] += arr[i]
	else:
		temp[i - arr[i]] = arr[i]
print(max(temp.values()))


import collections
import heapq
from bisect import bisect_right
import math
n = int(input())
arr = [int(x) for x in input().split()]
v = []
for i in range(n):
	v.append((arr[i] - i, i))
v.sort()
m = 0
count = v[0][1] + v[0][0]
l = v[0][0]
for i in range(1, n):
	if v[i][0] == l:
		count += v[i][1] + v[i][0]
	else:
		count = v[i][1] + v[i][0]
		l = v[i][0]
	m = max(m, count)
m = max(m, count)
print(m)


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
max_val = 0
valuedict = defaultdict(lambda : 0)
for i in range(n):
	if arr[i] - i in valuedict.keys():
		valuedict[arr[i] - i] += arr[i]
	else:
		valuedict[arr[i] - i] = arr[i]
for i in valuedict.values():
	max_val = max(max_val, i)
print(max_val)


n = int(input())
c = list(map(int, input().split()))
d = {}
for i in range(n):
	tmp = c[i] - i
	if not tmp in d:
		d[tmp] = 0
	d[tmp] += c[i]
print(max(d.values()))


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(len(l)):
	x = i + 1 - l[i]
	if x in d:
		d[x] += l[i]
	else:
		d[x] = l[i]
a = list(d.values())
print(max(a))


from collections import defaultdict
n = int(input())
b = map(int, input().split())
d = defaultdict(lambda : 0)
for (i, el) in enumerate(b):
	d[el - i] += el
print(max(d.values()))


n = int(input())
b = list(map(int, input().split()))
dif = []
m = 0
dicti = {}
for i in range(n):
	dif.append(b[i] - i)
	if dif[i] not in dicti:
		dicti[dif[i]] = b[i]
		if m < dicti[dif[i]]:
			m = dicti[dif[i]]
	else:
		dicti[dif[i]] += b[i]
		if m < dicti[dif[i]]:
			m = dicti[dif[i]]
print(m)


n = int(input())
l = list(map(int, input().split()))
c = {}
for i in range(n):
	j = l[i] - i
	if j not in c.keys():
		c[j] = l[i]
	else:
		c[j] += l[i]
print(max(c.values()))


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	n = int(input())
	arr = [int(i) for i in input().split()]
	from collections import defaultdict
	ans = defaultdict(int)
	for i in range(n):
		ans[arr[i] - i] += arr[i]
	print(max(ans.values()))
solution()


from collections import defaultdict
n = int(input())
l = list(map(int, input().split()))
dp = [0] * n
dp2 = [0] * 10 ** 6
for i in range(1, n + 1):
	dp[i - 1] = l[i - 1] - i
for i in range(n):
	dp2[dp[i]] += l[i]
print(max(dp2))


n = int(input())
b = [int(i) for i in input().split()]
k = 5 * 10 ** 5
z = [0] * 10 ** 6
for i in range(n):
	z[k + i - b[i]] += b[i]
print(max(z))


import sys
n = int(input())
b = list(map(int, input().split()))
d = {}
for i in range(n):
	v = b[i] - i
	if v in d.keys():
		d[v] += b[i]
	else:
		d[v] = b[i]
m = 0
for i in d.keys():
	m = max(m, d[i])
print(m)


size = int(input())
myList = list(map(int, input().split()))
capture = [0] * 800001
for k in range(size):
	capture[myList[k] - k] += myList[k]
print(max(capture))


t = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(t):
	f = a[i] - i
	if f not in d.keys():
		d[f] = a[i]
	else:
		d[f] += a[i]
print(max(d.values()))


from collections import defaultdict

def max_beauty(values):
	diff = [x - i for (i, x) in enumerate(values)]
	vals = defaultdict(int)
	for (i, x) in enumerate(diff):
		vals[x] += x + i
	return max(vals.values())
n = input()
lst = map(int, list(input().split()))
print(max_beauty(lst))


n = int(input())
b = list(map(int, input().split()))
g = {}
for j in range(n):
	g[b[j] - j] = g.get(b[j] - j, 0) + b[j]
print(max(g.values()))


n = int(input())
ans = 0
mp = {}
a = list(map(int, input().split()))
for i in range(n):
	if a[i] - (i + 1) not in mp:
		mp[a[i] - (i + 1)] = a[i]
	else:
		mp[a[i] - (i + 1)] += a[i]
	ans = max(ans, mp[a[i] - (i + 1)])
print(ans)


n = int(input())
b = list(map(int, input().split()))
final = {}
for i in range(n):
	if i - b[i] not in final:
		final[i - b[i]] = b[i]
	else:
		final[i - b[i]] += b[i]
ans = 0
for i in final:
	if final[i] > ans:
		ans = final[i]
print(ans)


n = int(input())
d = {}
a = []
[a.append(int(v) - int(i)) for (i, v) in enumerate(input().split())]
for i in range(n):
	d[a[i]] = d.get(a[i], 0) + a[i] + i
print(max(d.values()))


input()
z = dict()
i = 0
for k in map(int, input().split()):
	z[k - i] = z.get(k - i, 0) + k
	i += 1
print(max(z.values()))


n = int(input())
b = list(map(int, input().split()))
d = {}
maxi = 0
if n == 1:
	print(b[0])
else:
	for i in range(n):
		if i - b[i] not in d:
			d[i - b[i]] = [b[i]]
		else:
			d[i - b[i]].append(b[i])
	for i in d.keys():
		s = sum(d[i])
		if s > maxi:
			maxi = s
	print(maxi)


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque
from collections import defaultdict

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def prost(x):
	d = math.sqrt(x)
	d = int(d) + 1
	for i in range(2, d):
		if x % i == 0:
			return False
	return True

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
n = int(input())
a = list(map(int, input().split()))
dp = [0] * (8 * 100000)
for i in range(n):
	dp[a[i] - i] += a[i]
print(max(dp))


n = int(input())
a = []
dic = {}
x = list(map(int, input().split()))
for i in range(n):
	temp = x[i]
	a.append(temp)
	if temp - i in dic.keys():
		dic[temp - i] += temp
	else:
		dic[temp - i] = temp
ans = -1
for i in dic.keys():
	ans = dic[i] if ans < dic[i] else ans
print(ans)


n = int(input())
b = list(map(int, input().split(' ')))
ans = -1000
ATshayu = {}
for i in range(n):
	v = b[i] - i
	try:
		ATshayu[v] += b[i]
	except:
		ATshayu[v] = b[i]
	finally:
		ans = max(ans, ATshayu[v])
print(ans)


def fnc(a, t):
	dct = {}
	for i in range(t):
		if a[i] - (i + 1) not in dct:
			dct[a[i] - (i + 1)] = a[i]
		else:
			dct[a[i] - (i + 1)] += a[i]
	return dct
input()
a = list(map(int, input().split()))
d = fnc(a, len(a))
mx = 0
for key in d:
	if d[key] > mx:
		mx = d[key]
print(mx)


n = int(input())
lis = list(map(int, input().split()))
mat = [[lis[i], i] for i in range(n)]
mat.sort()
has = [0] * (8 * 101000)
for i in range(n):
	aa = mat[i][0] - mat[i][1]
	has[aa] += mat[i][0]
print(max(has))


n = int(input())
arr = list(map(int, input().split()))
x = dict()
for i in range(n):
	if i + 1 - arr[i] in x:
		x[i + 1 - arr[i]] += arr[i]
	else:
		x[i + 1 - arr[i]] = arr[i]
maxi = 0
for i in x:
	if x[i] > maxi:
		maxi = x[i]
print(maxi)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	from collections import defaultdict as dd
	c = dd(lambda : [])
	ans = -1
	for (idx, i) in enumerate(a):
		c[i - idx].append(idx)
		ans = max(ans, len(c))
	ans = -1
	for (key, val) in c.items():
		b = 0
		for i in val:
			b += a[i]
		ans = max(ans, b)
	print(ans)
	return
main()


import time
import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import bisect_left, bisect_right
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string, heapq as h
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def getInt():
	return int(input())

def getStrs():
	return input().split()

def getInts():
	return list(map(int, input().split()))

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def getBin():
	return list(map(int, list(input())))

def isInt(s):
	return '0' <= s[0] <= '9'

def ceil_(a, b):
	return a // b + (a % b > 0)
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	B = getInts()
	count = [0] * 600002
	for (i, b) in enumerate(B):
		count[b - i + 200001] += b
	return max(count)
print(solve())


from math import *
n = int(input())
arr = list(map(int, input().split()))
a = [(i - arr[i], arr[i]) for i in range(n)]
a.sort(key=lambda x: x[0], reverse=True)
priv = -inf
ans = 0
sum = 0
for i in a:
	if i[0] != priv:
		ans = max(ans, sum)
		sum = 0
		priv = i[0]
	sum += i[1]
ans = max(ans, sum)
print(ans)


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin, tan

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
d = dict()
n = ii()
a = li()
i = 1
mx = 0
for x in a:
	if x - i in d:
		d[x - i] += x
	else:
		d[x - i] = x
	mx = max(mx, d[x - i])
	i += 1
print(mx)


from collections import defaultdict

def main():
	for _ in range(1):
		n = int(input())
		arr = list(map(int, input().split()))
		a = [0] * n
		for i in range(n):
			a[i] = i + 1 - arr[i]
		c = defaultdict(int)
		for i in range(n):
			c[a[i]] += arr[i]
		print(max(c.values()))
main()


n = int(input())
ar = list(map(int, input().split()))
pref = []
for i in range(n):
	pref.append([])
	pref[-1].append(i + 1 - ar[i])
	pref[-1].append(i)
ans = []
pref.sort()
lst = pref[0][0]
s = ar[pref[0][1]]
for i in range(1, len(pref)):
	if pref[i][0] == lst:
		s += ar[pref[i][1]]
	else:
		ans.append(s)
		s = ar[pref[i][1]]
		lst = pref[i][0]
ans.append(s)
ans.sort()
print(ans[-1])


n = int(input())
b = [int(ele) for ele in input().split()]
diff = {}
for i in range(n):
	diff[b[i] - i] = 0
for i in range(0, n):
	diff[b[i] - i] += b[i]
maxi = 0
for key in diff.keys():
	maxi = max(maxi, diff[key])
print(maxi)


n = int(input())
dic = {}
arr = [int(k) for k in input().split()]
lis = []
dic = {}
for i in range(n):
	lis.append(arr[i] - (i + 1))
for i in range(n):
	if lis[i] not in dic:
		dic[lis[i]] = [i]
	else:
		dic[lis[i]].append(i)
maxi = 0
for (i, j) in dic.items():
	sum = 0
	for k in range(len(j)):
		sum = sum + arr[j[k]]
	maxi = max(sum, maxi)
print(maxi)


def f(a):
	dc = {}
	ans = 0
	for i in range(len(a)):
		dc[a[i] - i] = dc.get(a[i] - i, 0) + a[i]
		ans = max(ans, dc[a[i] - i])
	return ans
a = input()
l = list(map(int, input().strip().split()))
print(f(l))


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
from collections import defaultdict
from heapq import heappop, heappush, heapify
n = int(input())
l = list(map(int, input().split()))
hash = defaultdict(int)
maxi = -inf
for i in range(n):
	z = l[i] - i
	hash[z] += l[i]
	maxi = max(hash[z], maxi)
print(maxi)


MAXVAL = 4 * 10 ** 5
n = int(input())
beau = list(map(int, input().split()))
dp = [0] * (2 * MAXVAL + 2)
for i in range(n):
	dp[beau[i] - i - MAXVAL] += beau[i]
print(max(dp))


import sys
input = lambda : sys.stdin.readline().rstrip()
n = int(input())
a = [int(i) for i in input().split()]
ar = a[:]
for i in range(n - 1, -1, -1):
	a[i] += n - i - 1
d = {}
for i in range(n):
	if a[i] in d:
		d[a[i]].append(ar[i])
	else:
		d[a[i]] = [ar[i]]
maxx = 0
for i in d:
	maxx = max(maxx, sum(d[i]))
print(maxx)


n = int(input())
a = list(map(int, input().split()))
dic = dict()
for i in range(n):
	if a[i] - (i + 1) not in dic:
		dic[a[i] - (i + 1)] = []
		dic[a[i] - (i + 1)].append(a[i])
	else:
		dic[a[i] - (i + 1)].append(a[i])
s = 0
for i in dic.keys():
	s = max(s, sum(dic[i]))
print(s)


from collections import defaultdict
n = int(input())
y = list(map(int, input().split()))
arr = [0] * n
d = {}
d = defaultdict(lambda : [], d)
i = 0
while i < n:
	d[y[i] - i].append(y[i])
	i += 1
maxa = 0
for i in d.keys():
	s = sum(d[i])
	if maxa < s:
		maxa = s
print(maxa)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
numcities = int(input())
beauty = list(map(int, input().split()))
if numcities == 1:
	print(beauty[0])
else:
	list1 = []
	for k in range(numcities):
		beauty[k] = k + 1 - beauty[k]
	dict1 = {}
	for j in range(numcities):
		if not beauty[j] in dict1:
			dict1[beauty[j]] = [j + 1]
			list1.append(beauty[j])
		else:
			dict1[beauty[j]] += [j + 1]
	answer = 0
	for m in list1:
		beautysum = 0
		for n in dict1[m]:
			beautysum += n - m
		if beautysum > answer:
			answer = beautysum
	print(answer)


import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
dp = [0] * n
d = dict()
for i in range(n):
	if b[i] - i in d:
		dp[i] = dp[d[b[i] - i]] + b[i]
	else:
		dp[i] = b[i]
	d[b[i] - i] = i
print(max(dp))


n = int(input())
ar = list(map(int, input().split()))
m = [0 for i in range(2 * 4 * 100000)]
for i in range(n):
	m[i - ar[i]] += ar[i]
print(max(m))


from collections import Counter
n = int(input())
b = list(map(int, input().split()))
c = Counter()
for (i, v) in enumerate(b):
	c[v - i] += v
print(c[max(c, key=c.get)])


import math
n = int(input())
a = list(map(int, input().split()))
temp = [0] * n
for i in range(n):
	temp[i] = i - a[i]
dic = {}
for i in range(n):
	if temp[i] in dic:
		dic[temp[i]].append(a[i])
	else:
		dic[temp[i]] = [a[i]]
ans = -1
for key in dic:
	tempp = sum(dic[key])
	ans = max(ans, tempp)
print(ans)


n = int(input())
r = list(map(int, input().split()))
ans = 0
d = {}
if n == 1:
	print(r[0])
else:
	for i in range(n):
		r[i] -= i
		if r[i] not in d:
			d[r[i]] = r[i] + i
		else:
			d[r[i]] += r[i] + i
	ma = 0
	san = 0
	for i in d:
		if d[i] > ma:
			ma = d[i]
			san = i
	for i in range(n):
		if r[i] == san:
			ans += r[i] + i
	print(ans)


from math import *
from sys import stdin, stdout
input = stdin.buffer.readline
n = int(input())
a = [int(x) for x in input().split()]
val = []
for i in range(n):
	val.append([a[i] - i, a[i]])
val.sort()
v = val[0][1]
m = val[0][1]
for i in range(1, n):
	if val[i][0] == val[i - 1][0]:
		v += val[i][1]
	else:
		v = val[i][1]
	if m < v:
		m = v
print(m)


n = int(input())
arr = []
arr1 = []
arr3 = []
arr = list(map(int, input().split()))
for i in range(n):
	arr1.append(i + 1)
	arr1[i] = arr[i] - arr1[i]
c = {}
for j in range(0, n):
	c[arr1[j]] = 0
for j in range(0, n):
	c[arr1[j]] += arr[j]
arr3 = c.values()
b = max(arr3)
print(b)


import sys

def input():
	return sys.stdin.readline()[:-1]
n = int(input())
b = [int(x) for x in input().split()]
cnt = {}
ans = 0
for (i, e) in enumerate(b):
	if e - i not in cnt:
		cnt[e - i] = 0
	cnt[e - i] += e
	ans = max(ans, cnt[e - i])
print(ans)


import math, sys
from collections import defaultdict, Counter, deque
from functools import reduce
INF = float('inf')
MOD = int(1000000000.0) + 7

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = defaultdict(int)
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors[i] += 1
			n //= i
		i += 1
	if n > 1:
		factors[n] += 1
	return factors

def main():
	n = int(input())
	arr = array()
	diff = defaultdict(int)
	for i in range(n):
		d = arr[i] - (i + 1)
		diff[d] += arr[i]
	print(max(diff.values()))

class DSU:

	def __init__(self, n):
		self.p = [i for i in range(n + 1)]
		self.size = [1 for i in range(n + 1)]
		self.minmax = [[i, i] for i in range(n + 1)]
		self.n = n

	def find(self, node):
		if self.p[node] != node:
			self.p[node] = self.find(self.p[node])
		return self.p[node]

	def union(self, source, dest):
		source = self.find(source)
		dest = self.find(dest)
		if source != dest:
			if self.size[source] < self.size[dest]:
				(source, dest) = (dest, source)
			self.p[dest] = source
			self.size[source] += self.size[dest]
			mini = min(self.minmax[source][0], self.minmax[dest][0])
			maxi = max(self.minmax[source][1], self.minmax[dest][1])
			self.minmax[source] = [mini, maxi]

def input():
	return sys.stdin.readline().rstrip('\n')

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(sep)
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))
t = 1
for _ in range(t):
	main()


from collections import defaultdict as dd
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
d = dd(list)
n = inp(1)
l = inp()
for i in range(n):
	x = l[i] - i
	d[x].append(l[i])
ans = 0
for k in d:
	ans = max(ans, sum(d[k]))
print(ans)


import sys
I = lambda : int(input())
readline = lambda : sys.stdin.readline().strip('\n')
RM = readmap = lambda x=int: map(x, readline().split(' '))
d = {}
for (i, x) in zip(range(I()), RM()):
	d[x - i] = d.get(x - i, 0) + x
print(max(d.values()))
quit()
(n, a, b) = (I(), [*RM()], [*RM()])
(count1, count2) = (0, 0)
for (i, j) in zip(a, b):
	count1 += i & ~j
	count2 += j & ~i
print(divmod(count2, count1)[0] + 1 if count1 else -1)


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict

def solution(n, arr):
	arr.insert(0, 0)
	di = defaultdict(int)
	sub = [arr[i] - i for i in range(1, n + 1)]
	for (i, x) in enumerate(sub, start=1):
		di[x] += arr[i]
	write(max(di.values()))

def main():
	n = r_int()
	arr = r_array()
	solution(n, arr)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())

def p_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


n = int(input())
l = list(map(int, input().split()))
ans = []
d = {}
for i in range(len(l)):
	d[l[i] - i] = 0
for i in range(len(l)):
	ans.append(l[i] - i)
	d[l[i] - i] = d[l[i] - i] + l[i]
print(max(d.values()))


from sys import stdin as ip
n = int(ip.readline())
b = list(map(int, ip.readline().split()))
d = {}
for (i, x) in enumerate(b):
	v = i - x
	if v not in d:
		d[v] = [x]
	else:
		d[v].append(x)
ans = 0
for i in d:
	ans = max(ans, sum(d[i]))
print(ans)


n = int(input())
b = list(map(int, input().split()))
for i in range(n):
	b[i] = (b[i], b[i] - i)
b.sort(key=lambda x: x[1])
k = b[0][1]
mf = b[0][0]
s = b[0][0]
for i in range(1, n):
	if b[i][1] == k:
		s += b[i][0]
	else:
		k = b[i][1]
		mf = max(mf, s)
		s = b[i][0]
print(max(mf, s))


from collections import Counter
t = int(input())
l = list(map(int, input().split()))
l1 = [0] * t
ans = 0
dic = dict()
l2 = []
for i in range(t):
	l1[i] = l[i]
	ty = l[i] - i
	if ty in dic:
		dic[ty] += i
	else:
		dic[ty] = i
	l2.append(ty)
cc = Counter(l2)
ans = 0
for u in cc:
	ans = max(cc[u] * u + dic[u], ans)
print(ans)


import collections

def calc(b):
	(kv, res) = (collections.defaultdict(int), 0)
	for i in range(len(b)):
		kv[b[i] - (i + 1)] += b[i]
		res = max(kv[b[i] - (i + 1)], res)
	return res
N = int(input())
a = list(map(int, input().split()))
print(calc(a))


n = int(input())
b = [int(x) for x in input().split()]
d = {}
for i in range(n):
	d[b[i] - i] = d.get(b[i] - i, 0) + b[i]
print(max(d.values()))


import sys
input = sys.stdin.buffer.readline

def I():
	return list(map(int, input().split()))

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
n = int(input())
b = I()
marked = [-1] * n
marked[0] = 1
store = {1: b[0]}
currmax = b[0]
for i in range(1, n):
	marked[i] = marked[i - 1] + b[i] - b[i - 1] - 1
	store[marked[i]] = store.get(marked[i], 0) + b[i]
	currmax = max(currmax, store[marked[i]])
print(currmax)


n = int(input())
list1 = list(map(int, input().split()))
list2 = list()
for i in range(len(list1)):
	list2.append([list1[i] - (i + 1), list1[i]])
list2.sort()
maxi = 0
i = 0
while i < len(list2):
	sum = 0
	p = list2[i][0]
	while i < len(list2) and list2[i][0] == p:
		sum += list2[i][1]
		i += 1
	if sum > maxi:
		maxi = sum
print(maxi)


t = int(input())
str1 = input()
l1 = str1.split(' ')
l2 = []
l3 = []
for x in range(0, t):
	l2.append(int(l1[x]) - x)
for x in range(0, 400001):
	l3.append(0)
for x in range(0, t):
	l3[l2[x]] += int(l1[x])
z = max(l3)
if z == 400001:
	print(400000)
else:
	print(z)


import sys
import bisect
from collections import defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
n = int(data())
b = l()
c = []
for i in range(n):
	c.append((b[i] - i, b[i]))
c.sort()
d = [0] * n
d[0] = c[0][1]
for i in range(1, n):
	if c[i - 1][0] == c[i][0]:
		d[i] += c[i][1] + d[i - 1]
	else:
		d[i] += c[i][1]
print(max(d))


n = int(input())
b = [int(x) for x in input().split()]
cnt = {}
for i in range(1, n + 1):
	s = i - b[i - 1]
	if s in cnt.keys():
		cnt[s] += b[i - 1]
	else:
		cnt[s] = b[i - 1]
mx = 0
for (key, val) in cnt.items():
	mx = max(mx, val)
print(mx)


N = int(input())
beautylist = list(map(int, input().split()))
routes = [0 for i in range(N)]
metricset = set()
for (n, b) in enumerate(beautylist):
	metric = b - n
	metricset.add(metric)
metricdict = {metric: 0 for metric in metricset}
for (n, b) in enumerate(beautylist):
	metric = b - n
	metricdict[metric] += b
print(max(metricdict.values()))


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve(n, m):
	if n >= m:
		return n - m
	if m % 2:
		return 1 + solve(n, m + 1)
	return 1 + solve(n, m // 2)

def main():
	n = get_int()
	ls = get_list()
	dic = defaultdict(int)
	for (i, val) in enumerate(ls):
		dic[i - val] += val
	print(max(dic.values()))
TestCases = False
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


vals = dict()
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	beaut = l[i]
	ind = beaut - i
	if ind not in vals:
		vals[ind] = 0
	vals[ind] += beaut
best = 0
for v in vals:
	if vals[v] > best:
		best = vals[v]
print(best)


n = int(input())
b = list(map(int, input().split()))
dp = {}
for i in range(n):
	x = b[i] - i
	if x in dp:
		dp[x].append(b[i])
	else:
		dp[x] = [b[i]]
m = 0
for i in dp:
	m = max(sum(dp[i]), m)
print(m)


n = int(input().strip())
arr = list(map(int, input().strip().split()))
dic = {}
for i in range(n):
	key = arr[i] - (i + 1)
	if key not in dic:
		dic[key] = arr[i]
	else:
		dic[key] += arr[i]
print(max(dic.values()))


from sys import stdin
from collections import defaultdict
input = stdin.readline
n = int(input())
b = list(map(int, input().split()))
d = defaultdict()
for i in range(n):
	key = b[i] - i - 1
	d[key] = d.get(key, 0) + b[i]
print(max(list(d.values())))


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
n = inputnum()
b = inputlist()
c = [0] * 1000000
for i in range(n):
	c[b[i] - i] += b[i]
c.sort()
print(c[len(c) - 1])


from collections import Counter
from collections import defaultdict
import math
n = int(input())
a = list(map(int, input().split()))
l = list()
d = defaultdict(lambda : [])
for i in range(0, n):
	d[a[i] - i].append(a[i])
k = d.keys()
mx = 0
for i in k:
	s = d[i]
	ans = 0
	for j in s:
		ans = ans + j
	mx = max(mx, ans)
print(mx)


n = int(input())
b = [*map(int, input().split())]
g = {}
for i in range(n):
	g[b[i] - i] = g.get(b[i] - i, 0) + b[i]
print(max(g.values()))


class Solution:

	def getMaxBeauty(self, n: int, b) -> int:
		Hash = {}
		for i in range(n):
			Hash[b[i] - i] = Hash.get(b[i] - i, 0) + b[i]
		return max(Hash.values())
n = int(input())
b = list(map(int, input().split()))
obj = Solution()
print(obj.getMaxBeauty(n, b))


from collections import defaultdict
n = int(input())
by = map(int, input().split())
cc = defaultdict(int)
for (i, b) in enumerate(by):
	cc[b - i] += b
print(max(cc.values()))


n = int(input())
arr = list(map(int, input().split()))
result = [0] * n
maxx = 0
for i in range(n):
	result[i] = arr[i] - i
dic = {}
for i in range(n):
	if result[i] in dic:
		val = dic[result[i]]
		val += arr[i]
		dic[result[i]] = val
	else:
		val = arr[i]
		dic[result[i]] = val
	maxx = max(maxx, val)
print(maxx)


from collections import defaultdict
n = int(input())
arr = [int(i) for i in input().split()]
Dict = defaultdict(int)
for i in range(n):
	t = arr[i] - i
	Dict[t] += arr[i]
lis = list(Dict.values())
print(max(lis))


from collections import defaultdict
input()
vals = list(map(int, input().split()))
uwu = defaultdict(list)
[uwu[val - i].append(val) for (i, val) in enumerate(vals)]
print(max([sum(god) for god in uwu.values()]))


import collections as cc
f = cc.defaultdict(lambda : [])
d = cc.defaultdict(int)
n = int(input())
l = list(map(int, input().split()))
for i in range(n):
	d[l[i] - i] += l[i]
print(max(d.values()))


from collections import defaultdict
t = input()
b = list(map(int, input().split()))
g = defaultdict(int)
j = 0
for i in b:
	g[i - j] += i
	j += 1
print(max(g.values()))


n = int(input())
lst = [int(i) for i in input().split()]
max1 = 0
lst2 = []
dict1 = {}
for i in range(0, n):
	a = lst[i] - i
	if a not in dict1.keys():
		dict1[a] = lst[i]
	else:
		dict1[a] = dict1[a] + lst[i]
max1 = 0
for i in dict1.keys():
	if max1 < dict1[i]:
		max1 = dict1[i]
print(max1)


n = int(input())
l = list(map(int, input().split()))
d = {}
m = 0
for i in range(n):
	try:
		d[l[i] - i] += l[i]
	except:
		d[l[i] - i] = l[i]
	m = max(d[l[i] - i], m)
print(m)


n = int(input())
b = input().split()
for i in range(n):
	b[i] = int(b[i])
ls = [0 for i in range(2000000)]
for i in range(n):
	ls[b[i] - i] += b[i]
print(max(ls))


n = int(input())
b = list(map(int, input().split()))
count = {}
for (i, j) in enumerate(b):
	if j - i in count:
		count[j - i] += j
	else:
		count[j - i] = j
print(max(count.values()))


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, stdin.readline().split()))
ans = 0
value = defaultdict(lambda : 0)
for i in range(n):
	value[a[i] - i] += a[i]
	ans = max(ans, value[a[i] - i])
print(ans)


lens = int(input())
beut = [int(x) for x in input().split()]
dicts = {}
for i in range(lens):
	beut[i] -= i
	dicts[beut[i]] = dicts.get(beut[i], 0)
for i in range(lens):
	dicts[beut[i]] += beut[i] + i
print(max(dicts.values()))


import os
import sys
from math import *
from collections import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
n = int(input())
a = array()
d = [a[i] - i for i in range(n)]
c = Counter(d)
m = max(c.values())
ans = defaultdict(int)
for i in range(n):
	ans[d[i]] += a[i]
print(max(ans.values()))


def MaxBeauty(cities):
	types = [city - num for (num, city) in enumerate(cities)]
	journeys = dict()
	for num in range(len(cities)):
		try:
			journeys[types[num]] += cities[num]
		except KeyError:
			journeys[types[num]] = cities[num]
	return max(journeys.values())
assert MaxBeauty([111]) == 111
assert MaxBeauty([1, 1, 1]) == 1
assert MaxBeauty([1, 2, 3]) == 6
assert MaxBeauty([10, 7, 1, 9, 10, 15]) == 26
count = input()
cities = list(map(int, input().split()))
print(MaxBeauty(cities))


from bisect import bisect
n = int(input())
b = [int(p) for p in input().split()]
cntr = {}
for i in range(len(b)):
	try:
		cntr[b[i] - i - 1] += b[i]
	except KeyError:
		cntr[b[i] - i - 1] = b[i]
print(max(cntr.values()))


import sys
import copy
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def main():
	n = inp()
	b = inlt()
	hashm = {}
	ans = 0
	for i in range(0, n):
		if b[i] - i in hashm:
			hashm[b[i] - i] += b[i]
		else:
			hashm[b[i] - i] = b[i]
		ans = max(ans, hashm[b[i] - i])
	print(ans)
	return
main()


n = int(input())
l = list(map(int, input().split()))
d = []
for i in range(n):
	d.append([i - l[i], i])
d.sort()
ans = 0
i = 0
while i < n:
	t = d[i][0]
	c = 0
	while t == d[i][0]:
		c = c + l[d[i][1]]
		i = i + 1
		if i == n:
			break
	ans = max(ans, c)
print(ans)


n = int(input())
b = input().split()
mylist = []
for x in range(n):
	mylist.append([int(b[x]) - x, int(b[x])])
mylist = sorted(mylist)
gt = [0, 0]
a = mylist[0][0]
for x in range(n):
	if a != mylist[x][0]:
		if gt[1] > gt[0]:
			gt[0] = gt[1]
		gt[1] = 0
	gt[1] = gt[1] + mylist[x][1]
	a = mylist[x][0]
if gt[1] > gt[0]:
	gt[0] = gt[1]
print(gt[0])


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * 800001
for i in range(n):
	cnt[a[i] - i] += a[i]
print(max(cnt))


t = int(input())
l = list(map(int, input().split()))
a = [0] * t
for i in range(t):
	a[i] = l[i] - i - 1
s = [0] * t
su = [0] * t
z = set()
m = 0
for i in range(t):
	if a[i] in z:
		su[s.index(a[i])] += l[i]
	else:
		z.add(a[i])
		s[m] = a[i]
		su[m] = l[i]
		m += 1
print(max(su))


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
b = [a[i] - (i + a[0]) for i in range(n)]
d = defaultdict(int)
res = 0
for i in range(n):
	d[b[i]] += a[i]
	res = max(res, d[b[i]])
print(res)


import sys
lines = sys.stdin.readlines()
N = int(lines[0])
BV = list(map(int, lines[1].strip().split(' ')))
c = 0
d = 0
value = {}
for i in range(N):
	temp = BV[i] - i
	if temp not in value:
		value[temp] = BV[i]
	else:
		value[temp] += BV[i]
print(max(list(value.values())))


n = int(input())
b = [0] + list(map(int, input().split()))
p = [0 for i in range(n + 1)]
for i in range(1, n + 1):
	p[i] = b[i] - i
sum_ = [0 for i in range(10 ** 6)]
max_ = 0
for i in range(1, n + 1):
	sum_[p[i]] += b[i]
	if sum_[p[i]] > max_:
		max_ = sum_[p[i]]
print(max_)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
input = sys.stdin.readline
n = ii()
d = li()
r = [d[i] - i - 1 for i in range(n)]
m = dd()
for i in range(n):
	m[r[i]] += d[i]
print(max(m.values()))


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi
import math
from itertools import permutations
from copy import deepcopy

def main():
	n = int(input())
	b = list(map(int, input().split()))
	c = Counter()
	for (i, v) in enumerate(b):
		c[v - i] += v
	print(c[max(c, key=c.get)])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = [int(x) for x in input().split()]
b = []
for i in range(n):
	b += [a[i] - (i + 1)]
d = {}
for i in range(n):
	if b[i] not in d:
		d[b[i]] = a[i]
	else:
		d[b[i]] += a[i]
print(max(d.values()))


from sys import stdin
a = int(stdin.readline())
b = stdin.readline().split()
A = dict()
B = set()
for c in range(0, a):
	d = int(b[c]) - c
	e = len(B)
	B.add(d)
	if e == len(B):
		A[d] = A[d] + int(b[c])
	else:
		A[d] = int(b[c])
record = 0
for k in B:
	record = max(record, A[k])
print(record)


from collections import defaultdict
n = int(input())
b = list(map(int, input().split()))
dic = defaultdict(int)
for i in range(n):
	dic[b[i] - i] += b[i]
l = list(dic.values())
print(max(l))


input()
nums = list(map(int, input().split()))
res = {}
for (i, n) in enumerate(nums):
	if n - i not in res:
		res[n - i] = 0
	res[n - i] += n
print(max(res.values()))


import sys
import math
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
n = int(input())
b = read()
ans = -10 ** 9
d = {}
for i in range(n):
	try:
		d[b[i] - i]
	except KeyError:
		d[b[i] - i] = b[i]
	else:
		d[b[i] - i] += b[i]
for k in d.keys():
	ans = max(ans, d[k])
print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
b = list(map(int, input().split()))
d = {}
mv = 0
for i in range(n):
	v = b[i] - i
	if v in d:
		d[v] += b[i]
	else:
		d[v] = b[i]
	mv = max(mv, d[v])
print(mv)


n = int(input())
b = list(map(int, input().split()))
hashh = {}
for (pos, val) in enumerate(b):
	i = pos - val
	if i not in hashh:
		hashh[i] = val
	else:
		hashh[i] += val
mmax = 0
for val in hashh:
	mmax = max(mmax, hashh[val])
print(mmax)


n = int(input())
dic = {}
i = 0
for x in list(map(int, input().split())):
	dic[x - i] = dic.get(x - i, 0) + x
	i += 1
print(max(dic.values()))


from collections import defaultdict
n = int(input())
b = list(map(int, input().split()))
(ans, best) = (defaultdict(int), 0)
for i in range(n):
	ans[b[i] - i] += b[i]
	best = max(best, ans[b[i] - i])
print(best)


import sys
n = int(sys.stdin.readline())
l = list(map(int, sys.stdin.readline().split()))
val = [0 for i in range(800010)]
for i in range(n):
	val[i + 1 - l[i] + 400000] += l[i]
print(max(val))


n = int(input())
bi = list(map(int, input().split(' ')))
dic = {}
for i in range(n):
	val = bi[i] - i
	ans = dic.get(val, -1)
	if ans == -1:
		dic.update({val: bi[i]})
	else:
		dic.update({val: ans + bi[i]})
li = dic.values()
print(max(li))


n = int(input())
b = list(map(int, input().split()))
d = {}
for i in range(n):
	b[i] -= i
	d[b[i]] = 0
for i in range(n):
	d[b[i]] += b[i] + i
print(max(d.values()))


from collections import defaultdict
n = int(input())
b = list(map(int, input().split()))
i = 0
candidates = defaultdict(int)
for x in b:
	candidates[x - i] = candidates[x - i] + x
	i += 1
print(max(candidates.values()))


from collections import defaultdict
n = int(input())
bs = list(map(int, input().split()))
adjusted = [bci - ci for (ci, bci) in enumerate(bs)]
groups = defaultdict(int)
for (adj, b) in zip(adjusted, bs):
	groups[adj] += b
print(max(groups.values()))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter, defaultdict
from collections import deque
from functools import cmp_to_key
import math

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	n = iin()
	l = ain()
	for i in range(n):
		l[i] = i + 1 - l[i]
	d = dict()
	for i in range(n):
		if l[i] not in d:
			d[l[i]] = i + 1 - l[i]
		else:
			d[l[i]] += i + 1 - l[i]
	print(max(d.values()))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
collect = {}
i = 0
for x in map(int, input().split()):
	collect[x - i] = collect.get(x - i, 0) + x
	i += 1
print(max(collect.values()))


n = int(input())
b = list(map(int, input().split()))
a = b.copy()
for i in range(n):
	b[i] -= i
x = dict()
for i in range(n):
	if not x.get(b[i], False):
		x[b[i]] = 0
	x[b[i]] += a[i]
print(max(x.values()))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(1):
	n = int(input())
	b = list(map(int, input().split()))
	if n == 1:
		print(b[0])
		quit()
	di = {}
	for i in range(n):
		num = b[i]
		diff = num - i
		di[diff] = num if diff not in di else di[diff] + num
	ans = 0
	for w in sorted(di, key=di.get, reverse=True):
		ans = di[w]
		break
	print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
n = val()
l = li()
d = defaultdict(int)
for (ind, i) in enumerate(l):
	d[i - ind] = d[i - ind] + i
print(max(d.values()))


n = int(input())
l = list(map(int, input().split(' ')))
d = {}
for i in range(len(l)):
	s = str(l[i] - (i + 1))
	if s in d:
		d[s] += l[i]
	else:
		d[s] = l[i]
a = d.keys()
maxx = 0
for i in a:
	maxx = max(maxx, d[i])
print(maxx)


import sys
input = sys.stdin.readline
n = int(input())
robo = [int(i) for i in input().split()]
dict1 = dict()
max_ = 0
for i in range(n):
	diff = i + 1 - robo[i]
	if diff in dict1:
		dict1[diff] += robo[i]
		max_ = max(dict1[diff], max_)
	else:
		dict1[diff] = robo[i]
		max_ = max(dict1[diff], max_)
print(max_)


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = int(z())
l = zzz()
d = {}
i = 0
for x in l:
	d[x - i] = d.get(x - i, 0) + x
	i += 1
print(max(d.values()))


from collections import defaultdict
n = int(input())
b = [int(x) for x in input().split()]
reduced_beauty = [x - i for (i, x) in enumerate(b)]
results = defaultdict(int)
for i in range(n):
	results[reduced_beauty[i]] += b[i]
print(max(results.values()))


inf = int(10000000000.0)
n = int(input())
lis = list(map(int, input().split()))
c = sorted([(lis[i] - i, lis[i]) for i in range(n)])
v = c[0][1]
ans = 0
for i in range(1, n):
	if c[i - 1][0] == c[i][0]:
		v += c[i][1]
	else:
		ans = max(ans, v)
		v = c[i][1]
print(max(ans, v))


def main():
	from collections import defaultdict
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(lambda : [])
	for (i, v) in enumerate(a):
		d[v - i].append(v)
	ans = -1
	for (i, v) in d.items():
		ans = max(ans, sum(v))
	print(ans)
	return
main()


length = int(input())
beautyValues = list(map(int, input().split()))
c = []
sequence = []
sums = {}
for i1 in range(length):
	c.append(i1)
	sequence.append(beautyValues[i1] - i1)
for i1 in range(length):
	if sequence[i1] in sums.keys():
		sums[sequence[i1]] += beautyValues[i1]
	else:
		sums[sequence[i1]] = beautyValues[i1]
print(max(sums.values()))


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(n):
	if d.get(a[i] - i) != None:
		d[a[i] - i] += a[i]
	else:
		d[a[i] - i] = a[i]
print(max(d.values()))


n = int(input())
b = list(map(int, input().strip().split()))
dic = {}
for i in range(n):
	x = b[i] - i
	if x not in dic:
		dic[x] = b[i]
	else:
		dic[x] += b[i]
ans = 1
for k in dic:
	ans = max(ans, dic[k])
print(ans)


_ = input()
arr = list(map(int, input().split()))
d = {}
for (k, v) in enumerate(arr):
	if k - v in d:
		d[k - v] += v
	else:
		d[k - v] = v
print(max(d.values()))


n = int(input())
lst = list(map(int, input().split()))
dic = {}
for j in range(n):
	dic[lst[j] - j] = 0
for j in range(n):
	dic[lst[j] - j] += lst[j]
ma = -1000000000.0
for j in dic.keys():
	ma = max(ma, dic[j])
print(ma)


n = int(input())
ar = list(map(int, input().split()))
dp = [0] * 10 ** 6
for i in range(n):
	m = ar[i] - i
	dp[m] += ar[i]
print(max(dp))


n = int(input())
l = list(map(int, input().split()))
le = {}
bmax = 4 * 10 ** 5
offset = []
for i in range(n):
	x = l[i]
	off = l[i] - i
	offset.append(i)
	if off in le.keys():
		le[off] += l[i]
	else:
		le[off] = l[i]
maxoffset = 0
for x in le.keys():
	maxoffset = max(le[x], maxoffset)
print(maxoffset)


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
n = intput()
b = list(intsput())
groups = {}
for i in range(n):
	identity = b[i] - i
	if identity not in groups:
		groups[identity] = []
	groups[identity].append(b[i])
ans = max([sum(x) for x in groups.values()])
print(ans)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():
	n = int(input())
	bb = [int(a) for a in input().split()]
	seq = {}
	for (i, b) in enumerate(bb):
		if b - i in seq:
			seq[b - i] += b
		else:
			seq[b - i] = b
	print(max(seq.values()))
main()


from os import path
import sys, time, collections as c, math as m, pprint as p
(maxx, localsys, mod) = (float('inf'), 0, int(1000000000.0 + 7))
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
(b, cnt) = ([a[i] - (i + 1) for i in range(n)], c.defaultdict(list))
for i in range(n):
	cnt[b[i]].append(a[i])
print(max((sum(cnt[i]) for i in cnt)))


n = int(input().strip())
nums = [int(i) for i in input().strip().split()]
ans = [(nums[i] - (i + 1), i) for i in range(n)]
ans.sort()
a = nums[ans[0][1]]
s = ans[0][0]
temp = nums[ans[0][1]]
for i in range(1, n):
	if s != ans[i][0]:
		s = ans[i][0]
		a = max(a, temp)
		temp = nums[ans[i][1]]
		continue
	temp += nums[ans[i][1]]
print(max(a, temp))


n = int(input())
b = [int(i) for i in input().split()]
dupa = sorted([[b[i] - i, i] for i in range(n)])
max = 0
buf = dupa[0][0]
suma = 0
for x in dupa:
	if x[0] == buf:
		suma += b[x[1]]
	else:
		suma = b[x[1]]
		buf = x[0]
	if suma > max:
		max = suma
print(max)


n = int(input())
a = [int(i) for i in input().split()]
d = {}
for i in range(n):
	key = a[i] - i
	if key not in d.keys():
		d[key] = a[i]
	else:
		d[key] += a[i]
print(max(d.values()))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(1):
		n = ri()
		b = ria()
		cb = [0] * n
		for i in range(n):
			cb[i] = i - b[i]
		d = {}
		ans = 0
		for i in range(n):
			if cb[i] not in d:
				d[cb[i]] = b[i]
			else:
				d[cb[i]] += b[i]
			ans = max(ans, d[cb[i]])
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


n = int(input())
u = list(map(int, input().split()))
d = dict()
for i in range(n):
	cur = u[i] - i
	if cur in d.keys():
		d[cur] += u[i]
	else:
		d[cur] = u[i]
mx = 0
for i in d.keys():
	mx = max(mx, d[i])
print(mx)


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right
import math
n = int(input())
p = list(map(int, input().split()))
l = [i - p[i] for i in range(n)]
x = dc(int)
for i in range(n):
	x[l[i]] += p[i]
m = 0
for i in x.keys():
	m = max(m, x[i])
print(m)


n = int(input())
b = list(map(int, input().split()))
dic = {}
for (i, a) in enumerate(b, 1):
	x = a - i
	if dic.get(x, 0) == 0:
		dic[x] = a
	else:
		dic[x] += a
ans = -1
for i in dic.values():
	ans = max(ans, i)
print(ans)


from collections import defaultdict

def solve(N, B):
	chains = defaultdict(list)
	for (i, b) in enumerate(B):
		chains[b - i].append(b)
	return max((sum(v) for v in chains.values()))
(N,) = map(int, input().split())
B = list(map(int, input().split()))
ans = solve(N, B)
print(ans)


n = int(input())
a = list(map(int, input().split()))
r = {}
ans = 0
for i in range(n):
	r[i - a[i]] = r.get(i - a[i], 0) + a[i]
	ans = max(ans, r[i - a[i]])
print(ans)


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = 1
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		n = inp()
		b = inlt()
		hashm = {}
		for i in range(n):
			if b[i] - i in hashm:
				hashm[b[i] - i] = hashm[b[i] - i] + b[i]
			else:
				hashm[b[i] - i] = b[i]
		ans = 0
		for i in hashm:
			ans = max(ans, hashm[i])
		print(ans)
main()


input()
b = list(map(int, input().split()))
g = {}
j = 0
for i in b:
	g[i - j] = g.get(i - j, 0) + i
	j += 1
print(max(g.values()))


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	n = int(input())
	ar = inpt()
	d = defaultdict(int)
	mx = 0
	for i in range(n):
		d[ar[i] - i] += ar[i]
		mx = max(d[ar[i] - i], mx)
	print(mx)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
input()
best = defaultdict(int)
a = [int(x) for x in input().split()]
for (i, ai) in enumerate(a):
	best[ai - i] += ai
print(best[max(best, key=best.get)])


def iterativeDP(b, i, n):
	li = []
	for i in range(n):
		li.append([i - b[i], i])
	li.sort()
	i = 0
	mx = 0
	while i < n:
		j = i + 1
		(ll, sm) = (1, b[li[i][1]])
		while j < n and li[j][0] == li[i][0]:
			ll += 1
			sm += b[li[j][1]]
			j += 1
		if sm > mx:
			mx = sm
		i = j
	print(mx)
n = int(input())
b = [int(x) for x in input().split()]
iterativeDP(b, 0, n)


from collections import defaultdict as dd
n = int(input())
l = list(map(int, input().split()))
d = dd(int)
for i in range(n):
	d[l[i] - i] += l[i]
mx = -1
for i in d:
	if d[i] > mx:
		mx = d[i]
print(mx)


n = int(input())
x = []
j = 0
for i in input().strip().split(' '):
	x.append([j - int(i), int(i)])
	j += 1
x.sort()
last = x[0][0]
total = x[0][1]
mx = x[0][1]
for i in x[1:]:
	if i[0] == last:
		total += i[1]
	else:
		last = i[0]
		total = i[1]
	mx = max(mx, total)
print(mx)


from sys import stdin
n = int(stdin.readline().rstrip())
l = list(map(int, stdin.readline().rstrip().split(' ')))
m = 0
d = {}
j = 0
for i in l:
	v = d.get(i - j, 0) + i
	d[i - j] = v
	j += 1
	m = max(v, m)
print(m)


import collections

def solve(n, b_s):
	sums = collections.defaultdict(int)
	for i in range(n):
		diff = b_s[i] - i
		sums[diff] += b_s[i]
	return max(sums.values())
n = int(input())
b_s = [int(ch) for ch in input().split(' ')]
print(solve(n, b_s))


n = int(input())
b = list(map(int, input().split()))
pos = {}
for i in range(0, n):
	diff = b[i] - i
	if diff not in pos:
		pos[diff] = 0
	pos[diff] += b[i]
print(max(pos.values()))


input()
a = list(map(int, input().split()))
d = {}
j = 0
for i in a:
	d[i - j] = d.get(i - j, 0) + i
	j += 1
print(max(d.values()))


import math, sys
import heapq
from fractions import Fraction
from collections import Counter, defaultdict

def li():
	return list(map(int, sys.stdin.readline().split()))

def ls():
	return list(map(int, list(input())))

def la():
	return list(input())

def ii():
	return int(input())

def dic(x):
	return defaultdict(lambda : x)

def isPrime(n):
	i = 2
	if n == 1:
		return False
	while i <= int(math.sqrt(n)):
		if n % i == 0:
			return False
		i = i + 1
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def binarySearch(arr, x):
	(l, r) = (0, len(arr) - 1)
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return True
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return False
n = ii()
a = li()
index = []
total = 0
dic = {}
for i in range(n):
	if a[i] - i not in dic:
		dic[a[i] - i] = a[i]
	else:
		dic[a[i] - i] += a[i]
print(max(dic.values()))


n = int(input())
r = list(map(int, input().split()))
s = [r[i] - i - 1 for i in range(n)]
h = {}
ans = 0
for i in range(n):
	if str(s[i]) in h:
		h[str(s[i])] += r[i]
		ans = max(ans, h[str(s[i])])
	else:
		h[str(s[i])] = r[i]
		ans = max(ans, h[str(s[i])])
print(ans)


def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))
n = int(input())
b = liis()
begins = {}
for (i, v) in enumerate(b):
	if v - i not in begins:
		begins[v - i] = [v]
	else:
		begins[v - i].append(v)
ans = 0
for i in begins:
	ans = max(ans, sum(begins[i]))
print(ans)


inp = lambda : map(int, input().rstrip().split())
n = int(input())
b = list(inp())
d = dict()
for i in range(n):
	x = i + 1 - b[i]
	d[x] = d.get(x, 0) + b[i]
maxm = 0
for x in d:
	maxm = max(d[x], maxm)
print(maxm)


from collections import defaultdict as d
n = int(input())
b = [int(x) for x in input().split()]
groups = d(lambda : 0)
for i in range(n):
	groups[b[i] - i] += b[i]
print(max(groups.values()))


n = int(input())
c = {}
for (i, x) in enumerate(map(int, input().split())):
	d = x - i
	c[d] = c.get(d, 0) + x
print(max(c.values()))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(1):
	n = l()[0]
	s = l()
	A = [s[i] - i for i in range(n)]
	d = {}
	for i in range(n):
		if A[i] not in d:
			d[A[i]] = 0
		d[A[i]] += s[i]
	m = 0
	for k in d:
		m = max(m, d[k])
	print(m)


n = int(input())
b = [0]
b.extend(list(map(int, input().split())))
c = []
for i in range(1, n + 1):
	c.append([b[i] - i, i])
c.sort()
first = max(b)
i = 0
while i < n:
	j = i + 1
	beauty = c[i][0] + c[i][1]
	while j < n:
		if c[i][0] != c[j][0]:
			break
		else:
			beauty += c[j][0] + c[j][1]
		j += 1
	first = max([first, beauty])
	i = j
print(first)


from collections import defaultdict
t = int(input())
l = list(map(int, input().split()))
for i in range(t):
	l[i] = l[i] - i - 1
d = defaultdict(list)
for i in range(t):
	d[l[i]].append(i + 1)
max1 = float('-inf')
for i in d:
	max1 = max(sum(d[i]) + len(d[i]) * i, max1)
print(max1)


n = int(input())
q = [*map(int, input().split())]
w = [i + 1 - q[i] for i in range(n)]
e = {}
for i in range(n):
	if w[i] in e:
		e[w[i]] += q[i]
	else:
		e[w[i]] = q[i]
print(max(e.values()))


n = int(input())
arr = list(map(int, input().split()))
new = [ele - i for (i, ele) in enumerate(arr)]
ans = 0
s = dict()
for i in range(n):
	if new[i] not in s:
		s[new[i]] = arr[i]
	else:
		s[new[i]] += arr[i]
	ans = max(ans, s[new[i]])
print(ans)


q = int(input())
arr = list(map(int, input().split()))
keys = list(arr)
for x in range(q):
	keys[x] = keys[x] - x
dict1 = {}
for x in range(q):
	if keys[x] in dict1:
		dict1[keys[x]] += arr[x]
	else:
		dict1[keys[x]] = arr[x]
max1 = 0
for each in dict1:
	if dict1[each] > max1:
		max1 = dict1[each]
print(max1)


n = int(input())
b = list(map(int, input().split()))
if n == 1:
	print(b[0])
else:
	d = {}
	for i in range(n):
		b[i] -= i
		if b[i] not in d:
			d[b[i]] = [i]
		else:
			d[b[i]].append(i)
	b = sorted(b)
	x = 0
	ans = -1
	for i in range(n):
		if i == 0:
			x = b[i] + d[b[i]][-1]
			del d[b[i]][-1]
			if ans < x:
				ans = x
		elif b[i] == b[i - 1]:
			x += b[i] + d[b[i]][-1]
			del d[b[i]][-1]
			if ans < x:
				ans = x
		else:
			x = b[i] + d[b[i]][-1]
			del d[b[i]][-1]
			if ans < x:
				ans = x
	print(ans)


n = int(input())
b = list(map(int, input().split(' ')))
d = dict()
for i in range(n):
	try:
		d[b[i] - i] += b[i]
	except:
		d[b[i] - i] = b[i]
print(max(d.values()))


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_int():
	return int(sys.stdin.readline())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

def get_string():
	return sys.stdin.readline().strip()

def myceil(x, y):
	return (x + y - 1) // y

def Solution(arr, n):
	hm = {}
	for i in range(1, n + 1):
		v = i - arr[i - 1]
		if v in hm:
			hm[v] += arr[i - 1]
		else:
			hm[v] = arr[i - 1]
	ans = -1
	for key in hm:
		ans = max(ans, hm[key])
	print(ans)

def main():
	n = get_int()
	arr = get_ints_in_list()
	Solution(arr, n)
main()


n = int(input())
arr = list(map(int, input().split()))
sume = 0
arr2 = [[i + 1 - arr[i], arr[i]] for i in range(n)]
arr2 = sorted(arr2)
val = arr2[0][0]
sume = 0
maxe = 0
for i in range(n):
	if arr2[i][0] == val:
		sume += arr2[i][1]
	else:
		val = arr2[i][0]
		maxe = max(maxe, sume)
		sume = arr2[i][1]
print(max(maxe, sume))


n = int(input())
arr = list(map(int, input().split()))
t = [i + 1 - arr[i] for i in range(n)]
dic = {}
for i in range(n):
	try:
		dic[t[i]] += arr[i]
	except:
		dic[t[i]] = arr[i]
maxx = 0
for i in dic:
	maxx = max(maxx, dic[i])
print(maxx)


n = int(input())
b = list(map(int, input().split()))
numbers = dict()
_max = 0
for i in range(n):
	num = b[i] - i
	if num not in numbers:
		numbers[num] = b[i]
	else:
		numbers[num] += b[i]
	_max = max(_max, numbers[num])
print(_max)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		a[i] = (a[i] - i - 1, a[i])
	a.sort()
	i = 0
	ans = 0
	while i < n:
		j = i
		tmp = 0
		while j < n:
			if a[j][0] != a[i][0]:
				break
			tmp += a[j][1]
			j += 1
		if tmp > ans:
			ans = tmp
		i = j
	print(ans)
main()


n = int(input())
l = list(map(int, input().split()))
ls = [0] * 1000000
for i in range(n):
	ls[l[i] - i] += l[i]
print(max(ls))


n = range(1, int(input()) + 1)
vals = list(map(int, input().split()))
uwu = dict()
for i in n:
	d = vals[i - 1] - i
	if uwu.get(d) is None:
		uwu[d] = list()
	uwu[d].append((i, vals[i - 1]))
owo = list()
for item in uwu.items():
	(_, ps) = item
	owo.append(sum([p[-1] for p in ps]))
print(max(owo))


from collections import defaultdict
n = int(input())
bs = list(map(int, input().split(' ')))
chc = defaultdict(int)
for (i, b) in enumerate(bs):
	chc[b - i] += b
print(max(chc.values()))


n = int(input())
b = list(map(int, input().split()))
d = {}
for i in range(n):
	uniqCode = i - b[i]
	if uniqCode not in d:
		d[uniqCode] = []
	d[uniqCode].append(i)
maxV = 0
for places in d.values():
	v = 0
	for i in places:
		v += b[i]
	maxV = max(v, maxV)
print(maxV)


memo = [0] * 800007
n = int(input())
line = input().split()
for i in range(n):
	beauty = int(line[i])
	memo_index = 400002 + (beauty - i)
	memo[memo_index] += beauty
ans = 0
for elem in memo:
	ans = max(ans, elem)
print(ans)


from sys import stdin
from collections import Counter, defaultdict
n = int(stdin.readline())
ar = list(map(int, stdin.readline().split()))
dic = defaultdict(lambda : [])
for j in range(n):
	dic[ar[j] - j].append(ar[j])
m = 0
key = dic.keys()
for j in key:
	st = dic[j]
	a = 0
	for i in st:
		a += i
	m = max(m, a)
print(m)


import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	input()
	bb = LI()
	score = defaultdict(int)
	for (i, b) in enumerate(bb):
		d = b - i
		score[d] += b
	print(max(score.values()))
main()


import sys
input = sys.stdin.readline
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
	k = a[i] - i
	d[k] += a[i]
ans = max(d.values())
print(ans)


n = int(input())
arr = list(map(int, input().split()))
res = {}
for i in range(n):
	res[arr[i] - i] = arr[i] + res.get(arr[i] - i, 0)
ans = -1
for x in res:
	ans = max(ans, res[x])
print(ans)


n = int(input())
b = list(map(int, input().split()))
next_dest = [-1 for i in range(n)]
accumul = [b[i] for i in range(n)]
diff_to_b = {}
ans = 0
for i in range(n):
	if b[i] - i in diff_to_b:
		diff_to_b[b[i] - i] += b[i]
		if diff_to_b[b[i] - i] > ans:
			ans = diff_to_b[b[i] - i]
	else:
		diff_to_b[b[i] - i] = b[i]
		if diff_to_b[b[i] - i] > ans:
			ans = diff_to_b[b[i] - i]
print(ans)


n = int(input())
lst = [int(i) for i in input().split()]
Max = 0
d = {}
type(d)
for i in range(len(lst)):
	k = lst[i]
	d[k - i] = 0
for i in range(len(lst)):
	k = lst[i]
	d[k - i] = d[k - i] + k
	Max = max(d[k - i], Max)
print(Max)


num_cities = int(input())
beauty_values = [int(beauty) for beauty in input().split(' ')]
if num_cities > 1:
	for idx in range(num_cities):
		beauty_values[idx] = (beauty_values[idx], idx + 1 - beauty_values[idx])
	beauty_values.sort(key=lambda x: x[1])
	max_sums = []
	curr_sum = 0
	ptr1 = 0
	ptr2 = 1
	while ptr2 <= num_cities:
		curr_sum += beauty_values[ptr1][0]
		if ptr2 == num_cities:
			max_sums.append(curr_sum)
			curr_sum = 0
			ptr1 = ptr2
			ptr2 = ptr1 + 1
			continue
		elif beauty_values[ptr1][1] != beauty_values[ptr2][1]:
			max_sums.append(curr_sum)
			curr_sum = 0
			ptr1 = ptr2
			ptr2 = ptr1 + 1
			continue
		ptr1 += 1
		ptr2 += 1
	print(max(max_sums))
else:
	max_sums = beauty_values[0]
	print(max_sums)


n = int(input())
l = list(map(int, input().split()))
diff = []
for i in range(n):
	diff.append(l[i] - i - 1)
dic = dict()
for i in range(n):
	if diff[i] not in dic.keys():
		dic[diff[i]] = l[i]
	else:
		dic[diff[i]] += l[i]
ma = 0
for value in dic.values():
	if value >= ma:
		ma = value
print(ma)


n = int(input())
b = list(map(int, input().split()))
List = []
for i in range(n):
	List.append([b[i] - (i + 1), b[i]])
List.sort()
maxim = 0
for i in range(1, len(List)):
	if List[i][0] == List[i - 1][0]:
		List[i][1] += List[i - 1][1]
	maxim = max(List[i][1], maxim)
print(max(b[0], maxim))


q = 1
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	a = [0] * 10 ** 6
	m = []
	for i in range(n):
		m.append(l[i] - i)
	for i in range(n):
		a[m[i]] += l[i]
	print(max(a))


import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
arrLim = 2 * 10 ** 5 + 7
s = [0] * 4 * arrLim
for i in range(n):
	s[b[i] - i + arrLim] += b[i]
print(max(s))


from collections import defaultdict
n = int(input())
b = list(map(int, input().split()))
c = [i for i in range(1, n + 1)]
diff = [c[i] - b[i] for i in range(n)]
d = defaultdict(list)
for i in range(len(diff)):
	d[diff[i]].append(i)
r = 0
for i in d:
	curr = d[i]
	curr_r = 0
	for j in curr:
		curr_r += b[j]
	r = max(r, curr_r)
print(r)


n = int(input())
li = list(map(int, input().split()))
d = {}
for i in range(len(li)):
	try:
		d[li[i] - i] += li[i]
	except:
		d[li[i] - i] = li[i]
mx = -1
for (k, v) in d.items():
	if mx < v:
		mx = v
print(mx)


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	return [[default for j in range(m)] for i in range(n)]

def arr3D(n, m, r, default=0):
	return [[[default for k in range(r)] for j in range(m)] for i in range(n)]

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

class DSU:

	def __init__(self, length):
		self.length = length
		self.parent = [-1] * self.length

	def getParent(self, node, start):
		if node >= self.length:
			return False
		if self.parent[node] < 0:
			if start != node:
				self.parent[start] = node
			return node
		return self.getParent(self.parent[node], start)

	def union(self, node1, node2):
		parent1 = self.getParent(node1, node1)
		parent2 = self.getParent(node2, node2)
		if parent1 == parent2:
			return False
		elif self.parent[parent1] <= self.parent[parent2]:
			self.parent[parent1] += self.parent[parent2]
			self.parent[parent2] = parent1
		else:
			self.parent[parent2] += self.parent[parent1]
			self.parent[parent1] = parent2
		return True

	def getCount(self, node):
		return -self.parent[self.getParent(node, node)]

def exact(num):
	if abs(num - round(num)) <= 10 ** (-9):
		return round(num)
	return num

def solve(n, lst):
	for i in range(n):
		lst[i] = lst[i] - i
	sumMap = {}
	for i in range(n):
		if sumMap.get(lst[i]) == None:
			sumMap[lst[i]] = 0
		sumMap[lst[i]] += i + lst[i]
	maxx = -1
	for i in sumMap:
		maxx = max(maxx, sumMap[i])
	return maxx
n = int(input())
lst = list(map(int, input().split()))
print(solve(n, lst))


def go():
	n = int(input())
	b = list(map(int, input().split()))
	d = {}
	for (i, bb) in enumerate(b):
		d[bb - i] = d.get(bb - i, 0) + bb
	return max(d.values())
print(go())


n = int(input())
l = list(map(int, input().split()))
d = {}
for t in range(n):
	d[l[t] - t] = d.get(l[t] - t, 0) + l[t]
print(max(d.values()))


from collections import defaultdict
n = int(input())
lst = list(map(int, input().split()))
d = defaultdict(list)
ans = []
for i in range(len(lst)):
	d[i - lst[i]].append(lst[i])
for (a, b) in d.items():
	ans.append(sum(b))
ans.sort(reverse=True)
print(ans[0])


import math
n = int(input())
b = list(map(int, input().split()))
for i in range(n):
	b[i] = b[i] - i
m = {}
for i in range(n):
	if b[i] not in m:
		m[b[i]] = b[i] + i
	else:
		m[b[i]] += b[i] + i
answer = 0
for key in m:
	answer = max(answer, m[key])
print(answer)


n = int(input())
b = list(map(int, input().split()))
lst = []
for i in range(n):
	lst.append(i - b[i])
d = {}
for i in range(n):
	d[lst[i]] = d.get(lst[i], 0) + b[i]
print(max(d.values()))


from sys import stdin, stdout
import traceback
import math
from collections import defaultdict
read = stdin.readline
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def reads(typ=int):
	return list(map(typ, read().split()))

class Sol:

	@classmethod
	def input(cls):
		s = cls()
		return s

	def solve(self):
		n = int(read())
		bs = reads()
		cs = defaultdict(list)
		for (i, b) in enumerate(bs):
			c = b - i
			cs[c].append(b)
		ret = 0
		for (c, v) in cs.items():
			tmp = sum(v)
			if tmp > ret:
				ret = tmp
		return ret
try:
	writeln(Sol.input().solve())
except Exception as e:
	print('Got exception:', repr(e))
	print(traceback.format_exc())


from collections import defaultdict
n = int(input())
l = list(map(int, input().split()))
d = defaultdict(int)
for i in range(len(l)):
	d[l[i] - i] += l[i]
m = 0
for i in d:
	m = max(m, d[i])
print(m)


n = int(input())
l = [0] + list(map(int, input().split()))
d = dict()
ls = [(0, 0)]
for i in range(1, n + 1):
	xs = l[i] - i
	ys = (xs, l[i])
	ls.append(ys)
for i in range(1, n + 1):
	(x, y) = (ls[i][0], ls[i][1])
	if x not in d:
		d[x] = 0
	d[x] += y
ax = 0
for i in d.keys():
	ax = max(d[i], ax)
print(ax)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = list(map(int, input().split()))
l1 = l.copy()
from collections import defaultdict
d = defaultdict(int)
ans = 0
for i in range(n):
	l1[i] = l1[i] - i
for i in range(n):
	d[l1[i]] += l[i]
	ans = max(ans, d[l1[i]])
print(max(ans, max(l)))


def a():
	n = int(input())
	b = list(map(int, input().strip().split()))
	d = {}
	for i in range(n):
		if b[i] - i - 1 not in d:
			d[b[i] - i - 1] = 0
		d[b[i] - i - 1] += b[i]
	ans = -1
	for k in d:
		ans = max(ans, d[k])
	print(ans)
a()


n = int(input())
l = [int(j) for j in input().split()]
d = dict()
for i in range(n):
	if l[i] - i in d:
		d[l[i] - i] += l[i]
	else:
		d[l[i] - i] = l[i]
mx = 0
for key in d:
	mx = max(mx, d[key])
print(mx)


n = int(input())
b_aux = input().split()
b = []
for i in range(n):
	b.append((int(b_aux[i]) - i, int(b_aux[i])))
a = sorted(b)
current = a[0][0] - 1
cont = 0
res = -1
for e in a:
	if e[0] == current:
		cont += e[1]
	else:
		res = max(res, cont)
		cont = e[1]
		current = e[0]
res = max(cont, res)
print(res)


n = int(input())
ls = [int(x) for x in input().split()]
d = dict()
for i in range(n):
	x = ls[i] - i
	if x in d:
		d[x] += ls[i]
	else:
		d[x] = ls[i]
ans = -1
for i in d:
	ans = max(ans, d[i])
print(ans)


from sys import stdin, stdout
import math
n = int(stdin.readline().rstrip())
b = list(map(int, stdin.readline().rstrip().split(' ')))
scores = [0] * (6 * 10 ** 5)
for i in range(n):
	ind = i - b[i] + 4 * 10 ** 5
	scores[ind] += b[i]
print(max(scores))


n = int(input())
arr = list(map(int, input().split()))
m = {}
for i in range(n):
	z = arr[i] - i
	if z in m:
		m[z] += arr[i]
	else:
		m[z] = arr[i]
print(max(m.values()))


n = int(input())
s = list(map(int, input().split()))
g = {}
r = 0
for i in range(n):
	g[s[i] - i] = g.get(s[i] - i, 0) + s[i]
	r = max(r, g[s[i] - i])
print(r)


from collections import defaultdict as dc
x = int(input())
s = list(map(int, input().split()))
d = dc(lambda : 0)
for n in range(x):
	d[s[n] - n - 1] += s[n]
mx = 0
for n in d:
	mx = max(mx, d[n])
print(mx)


from collections import defaultdict as dd
n = int(input())
b = list(map(int, input().split()))
g = dd(list)
for i in range(n):
	g[b[i] - i].append(b[i])
print(max((sum(i) for i in g.values())))


from collections import Counter

def solve(n, a):
	diffs = [0] * n
	for i in range(n):
		diffs[i] = a[i] - i
	d = {}
	for i in range(n):
		d[diffs[i]] = d.get(diffs[i], 0) + a[i]
	return max(d.values())
n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


t = int(input())
l = list(map(int, input().split()))
l1 = [0] * t
ans = 0
dic = dict()
ans = 0
for i in range(t):
	l1[i] = l[i]
	ty = l[i] - i
	if ty in dic:
		dic[ty] += l[i]
	else:
		dic[ty] = l[i]
	ans = max(dic[ty], ans)
print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
beauti = list(map(int, input().split()))
res = 0
dic = {}
newlen = 0
for i in range(t):
	realval = beauti[i] - i
	getit = dic.get(realval, 0)
	dic[realval] = getit + beauti[i]
print(dic[max(dic, key=dic.get)])


n = int(input())
l = list(map(int, input().split()))
if n == 1:
	print(l[0])
else:
	d = {}
	for i in range(n):
		if l[i] - i not in d:
			d[l[i] - i] = [l[i]]
		else:
			d[l[i] - i].append(l[i])
	r = max([sum(i) for i in d.values()])
	print(r)


import os
import sys

def main():
	n = int(input())
	b = list(map(int, input().split()))
	ls = [0 for i in range(2000000)]
	for i in range(n):
		ls[b[i] - i] += b[i]
	print(max(ls))
main()


n = int(input())
temparr = input()
temparr = temparr.split()
arr = []
index = 1
for i in temparr:
	arr.append(int(i) - index)
	index += 1
dicts = {}
for i in range(n):
	if arr[i] not in dicts:
		dicts[arr[i]] = []
	dicts[arr[i]].append(arr[i] + i)
maxs = 0
for (key, value) in dicts.items():
	nn = len(value)
	curtotal = sum(value) + nn
	if curtotal > maxs:
		maxs = curtotal
print(maxs)


from collections import defaultdict

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	m = 0
	for i in range(n):
		d[a[i] - i] += a[i]
		m = max(m, d[a[i] - i])
	print(m)
solve()


n = int(input())
l = list(map(int, input().split()))
r = []
ls = [0] * 2000000
for i in range(n):
	ls[l[i] - i] += l[i]
print(max(ls))


num_city = int(input())
beautys = list(map(int, input().split()))
offsets = {}
for i in range(num_city):
	b = beautys[i]
	off = b - i
	if off in offsets:
		offsets[off].append(b)
	else:
		offsets[off] = [b]
max_ = 0
for key in offsets:
	val = sum(offsets[key])
	max_ = max(max_, val)
print(max_)


pathScores = dict()
numCities = int(input())
beauties = [int(i) for i in input().split()]
for cNum in range(numCities):
	key = beauties[cNum] - cNum
	if key in pathScores:
		pathScores[key] += beauties[cNum]
	else:
		pathScores[key] = beauties[cNum]
print(pathScores[max(pathScores, key=pathScores.get)])


import sys
n = int(sys.stdin.readline().strip())
b = list(map(int, sys.stdin.readline().strip().split()))
a = [0] * n
for i in range(0, n):
	a[i] = b[i] - i
x = [0] * 10 ** 6
for i in range(0, n):
	x[3 * 10 ** 5 + a[i]] = x[3 * 10 ** 5 + a[i]] + b[i]
print(max(x))


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()
out = []

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	n = iin()
	b = lin()
	mx = 4 * 10 ** 5 + 1
	b = [[j, i] for (i, j) in enumerate(b)]
	b.sort()
	b1 = [0 for i in range(2 * mx)]
	for (i, j) in b:
		b1[i - j] += i
	print(max(b1))
main()


n = int(input())
B = list(map(int, input().split()))
d = {}
for (i, b) in enumerate(B):
	t = b - i
	if t not in d:
		d[t] = b
	else:
		d[t] += b
print(max(d.values()))


n = int(input())
b = list(map(int, input().split()))
a = [b[i] - i for i in range(n)]
d = {}
for i in range(n):
	if a[i] not in d:
		d[a[i]] = b[i]
	else:
		d[a[i]] += b[i]
print(max(list(d.values())))


from collections import defaultdict
input()
arr = list(map(int, input().split()))
dct = defaultdict(lambda : 0)
for (i, elem) in enumerate(arr):
	dct[elem - i] += elem
print(max(dct.values()))


n = int(input())
ls = [int(i) for i in input().split()]
d = dict()
for i in range(len(ls)):
	if ls[i] - i not in d:
		d[ls[i] - i] = ls[i]
	else:
		d[ls[i] - i] += ls[i]
print(max(d.values()))


n = int(input())
a = list(map(int, input().split()))
c = [0] * (n + max(a))
i = 0
while i < n:
	b = a[i] + (n - i - 1)
	c[b] += a[i]
	i += 1
print(max(c))


n = int(input())
b = [0 for i in range(n + 1)]
b[1:] = list(map(int, input().split()))
for i in range(1, n + 1):
	b[i] = b[i] - i
l = list(enumerate(b[1:], 1))
l.sort(reverse=True, key=lambda x: x[1])
d = maxsum = l[0][0] + l[0][1]
for j in range(1, n):
	if l[j][1] == l[j - 1][1]:
		d += l[j][1] + l[j][0]
	else:
		if d > maxsum:
			maxsum = d
		d = l[j][0] + l[j][1]
if d > maxsum:
	maxsum = d
print(maxsum)


def f():
	graph = [[2, 4, 5, 8], [5, 7, 3], [0, 4, 6, 5], [1, 9], [0, 2, 6], [0, 2, 1], [2, 4], [2, 1], [0, 11, 10], [3], [8, 11], [8, 10]]
	sptr = list()
	dfs(0, [False] * len(graph), graph, sptr)
	print(sptr)

def dfs(u, visited, graph, sptr):
	print(u)
	visited[u] = True
	for v in graph[u]:
		if visited[v] == False:
			Mark(u, v, sptr)
			dfs(v, visited, graph, sptr)
		else:
			pass

def Mark(u, v, sptr):
	sptr.append((u + 1, v + 1))

def f1320A():
	n = int(input())
	beauty_array = [int(bi) for bi in input().split(' ')]
	array = [(i + 1 - beauty_array[i], i) for i in range(0, len(beauty_array))]
	array.sort(key=lambda x: x[0])
	ssum = 0
	maxsum = 0
	singlesum = -1
	end_index = 0
	for i in range(0, len(array)):
		if i > 0:
			if array[i - 1][0] != array[i][0]:
				if maxsum < ssum:
					maxsum = ssum
					ssum = 0
				ssum = beauty_array[array[i][1]]
			else:
				ssum = ssum + beauty_array[array[i][1]]
				if maxsum < ssum:
					maxsum = ssum
		else:
			ssum = beauty_array[array[i][1]]
			maxsum = beauty_array[array[i][1]]
	print(maxsum)
f1320A()


n = int(input())
b = [0] + list(map(int, input().split()))
dp = [0 for i in range(n + 1)]
ez = {}
for i in range(1, n + 1):
	res = b[i]
	if b[i] - i in ez:
		res = max(res, ez[b[i] - i] + b[i])
	dp[i] = res
	if b[i] - i not in ez:
		ez[b[i] - i] = res
	else:
		ez[b[i] - i] = max(ez[b[i] - i], res)
print(max(dp))


import os, sys
from io import BytesIO, IOBase
from collections import Counter

def main():
	n = int(input())
	b = list(map(int, input().split()))
	dct = Counter()
	for (ind, i) in enumerate(b):
		dct[i - ind] += i
	print(dct[max(dct, key=dct.get)])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math
n = int(input())
arr = list(map(int, input().split()))
dp = [0] * n
ans = 0
d = {}
for i in range(n):
	if arr[i] - i in d:
		d[arr[i] - i] += arr[i]
	else:
		d[arr[i] - i] = arr[i]
	ans = max(ans, d[arr[i] - i])
print(ans)


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
int1 = lambda x: int(x) - 1
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
ilelec = lambda : map(int1, input().split())
alelec = lambda : list(map(int1, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
n = int(input())
A = alele()
G = {}
pos = 0
for i in A:
	pos += 1
	G[i - pos] = G.get(i - pos, 0) + i
print(max(G.values()))


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = mpos(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj
import sys
import threading
from math import *
sys.setrecursionlimit(300000)
threading.stack_size(10 ** 8)
po = int(log(10 ** 18)) + 2
li = []
for i in range(po):
	li.append(3 ** i)
li = li[::-1]
s = sum(li)
for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	check = [i - a[i] for i in range(n)]
	cnt = {}
	for i in range(n):
		if check[i] not in cnt:
			cnt[check[i]] = a[i]
		else:
			cnt[check[i]] += a[i]
	print(max(cnt.values()))


from itertools import groupby

def keyfunc(key):
	return key[0] - key[1]
input()
arr = list(map(int, input().split()))
ans = max(map(lambda g: sum(list(zip(*g[1]))[1]), groupby(sorted(enumerate(arr), key=keyfunc), keyfunc)))
print(ans)


import sys
input = sys.stdin.readline
n = int(input())
b = list(map(int, input().split()))
DP = [b[i] for i in range(n)]
fk = {}
for i in range(n):
	k = i - b[i]
	if k in fk.keys():
		j = fk[k]
		if j - b[j] == k:
			DP[i] = max(DP[i], DP[j] + b[i])
	fk[k] = i
print(max(DP))


from sys import stdin, stdout
s = stdin.readline()
a = list(map(int, stdin.readline().split()))
d = {}
j = 0
for i in a:
	d[i - j] = d.get(i - j, 0) + i
	j += 1
print(max(d.values()))


import sys
import bisect
import collections

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	arr = get_list()
	for i in range(n):
		arr[i] = arr[i] - i - 1
	counter = {}
	for i in range(n):
		ele = arr[i]
		if ele not in counter:
			counter[ele] = ele + i + 1
		else:
			counter[ele] += ele + i + 1
	ans = 0
	for i in counter:
		val = counter[i]
		ans = max(ans, val)
	print(ans)


n = int(input())
r = list(map(int, input().split()))
r1 = []
ans = [0] * 10 ** 6
for i in range(n):
	r1.append(r[i] - i)
for i in range(n):
	ans[r1[i]] += r[i]
print(max(ans))


t = 1
while t:
	t -= 1
	n = int(input())
	b = list(map(int, input().split()))
	offset = dict()
	for i in range(n):
		temp = i - b[i]
		if temp in offset:
			offset[temp] += b[i]
		else:
			offset[temp] = b[i]
	print(sorted(list(offset.values()))[-1])


n = int(input())
b = list(map(int, input().split()))
d = {}
for i in range(n):
	if i - b[i] in d:
		d[i - b[i]] += b[i]
	else:
		d[i - b[i]] = b[i]
m = 0
for i in d.values():
	if m < i:
		m = i
print(max(max(b), m))


n = int(input())
arr = list(map(int, input().split()))
s = {}
ans = 0
for i in range(0, n):
	if arr[i] - i - 1 not in s:
		s[arr[i] - i - 1] = [arr[i]]
	else:
		s[arr[i] - i - 1].append(arr[i])
for j in s:
	ans = max(ans, sum(s[j]))
print(ans)


from math import *
from collections import *
from operator import itemgetter
import bisect
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
I = lambda : list(map(int, input().split()))
dd = defaultdict(lambda : [])
t = ii()
a = iia()
d = [0] * t
m = 0
for i in range(t):
	d[i] = a[i] - i
for j in range(t):
	dd[d[j]].append(a[j])
dd = dict(dd)
mx = 0
for i in dd:
	mx = max(mx, sum(dd[i]))
print(mx)


from collections import defaultdict
n = int(input())
list1 = list(map(int, input().split()))
d = defaultdict(int)
maxi = 0
for i in range(n):
	d[list1[i] - (i + 1)] += list1[i]
	maxi = max(maxi, d[list1[i] - (i + 1)])
print(maxi)


n = int(input())
beauty = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic[i - beauty[i]] = dic.get(i - beauty[i], 0) + beauty[i]
print(max(dic.values()))


import sys
input = sys.stdin.readline
n = int(input())
it = list(map(int, input().split()))
s = {}
for i in range(n):
	try:
		x = s[i - it[i]]
		s[i - it[i]] += it[i]
	except:
		s[i - it[i]] = it[i]
print(max(s.values()))


from math import *
n = int(input())
b = [int(i) for i in input().split()]
c = b[:]
dp = []
for i in range(n):
	b[i] -= i
d = {}
for i in range(n):
	if b[i] not in d:
		d[b[i]] = c[i]
	else:
		d[b[i]] += c[i]
print(max(d.values()))


n = int(input())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	if i - l[i] in d:
		d[i - l[i]].append(l[i])
	else:
		d[i - l[i]] = [l[i]]
a = []
for i in d.items():
	a.append(sum(i[1]))
print(max(a))


x = int(input())
a = list(map(int, input().split()))
b = {}
for i in range(x):
	tem = a[i]
	if tem - i in b.keys():
		b[tem - i] += tem
	else:
		b[tem - i] = tem
print(max(b.values()))


n = int(input())
b = list(map(int, input().split()))
l = [[] for i in range(10 ** 6)]
d = [b[i] - (i + 1) for i in range(n)]
for i in range(n):
	l[d[i]].append(b[i])
ans = -1
for i in range(len(l)):
	if l[i]:
		ans = max(ans, sum(l[i]))
print(ans)


n = int(input())
a = list(map(int, input().split()))
d = {}
mx = 0
for i in range(n):
	dif = a[i] - i
	d[dif] = d.get(dif, 0) + a[i]
	mx = max(mx, d[dif])
print(mx)


n = int(input())
a = list(map(int, input().strip().split()))
b = []
for i in range(n):
	b.append(a[i] - i)
c = {}
for i in range(n):
	c[b[i]] = []
for i in range(n):
	c[b[i]].append(a[i])
d = []
for i in c:
	d.append(sum(c[i]))
print(max(d))


n = int(input())
b = [int(i) for i in input().split()]
pp = dict()
for i in range(n):
	key = b[i] - i
	if key not in pp:
		pp[key] = b[i]
	else:
		pp[key] = pp[key] + b[i]
print(pp[max(pp, key=pp.get)])


from sys import stdin

def get_input():
	return int(stdin.readline())

def multiple_input():
	return map(int, stdin.readline().split())

def list_input():
	return list(map(int, stdin.readline().split()))
n = get_input()
a = list_input()
dp = [0] * n
d = {}
for i in range(n):
	if a[i] - i in d:
		dp[i] = dp[d[a[i] - i]] + a[i]
	else:
		dp[i] = a[i]
	d[a[i] - i] = i
print(max(dp))


n = int(input())
(*b,) = map(int, input().split())
cities = {}
starts_idx = [-1 for _ in range(n)]
ends_idx = [-1 for _ in range(n)]
cur_val = [0 for _ in range(n)]
for i in range(n):
	cities.setdefault(b[i] - i, [])
	cities[b[i] - i].append(b[i])
print(max((sum(route) for route in cities.values())))


n = int(input())
b = list(map(int, input().split()))
p = [0] * 10 ** 6
for i in range(n):
	a = b[i] - i
	p[a] += b[i]
print(max(p))


n = int(input())
arr = list(map(int, input().split()))
B = [-1] * n
dct = dict()
for i in range(n):
	B[i] = arr[i] - i
for i in range(n):
	if B[i] in dct:
		dct[B[i]] += arr[i]
	else:
		dct[B[i]] = arr[i]
print(max(dct.values()))


n = int(input())
a = list(map(int, input().split()))
d = dict()
for i in range(n):
	k = a[i] - i
	if k in d:
		d[k] += a[i]
	else:
		d[k] = a[i]
print(max(d.values()))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	a = lis()
	dp = {}
	for i in range(n):
		if a[i] - i in dp:
			dp[a[i] - i].append(a[i])
		else:
			dp[a[i] - i] = [a[i]]
	ans = 0
	for i in dp:
		ans = max(ans, sum(dp[i]))
	print(ans)
testcase(1)


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(val)
(n,) = mp()
b = mp()
d = {}
maxx = count = 0
visited = [0] * (n + 1)
for i in range(n):
	d[i - b[i]] = d.get(i - b[i], 0) + b[i]
cout(str(max(d.values())))


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
dic = {}
for (i, a) in enumerate(A):
	b = a - i
	if b in dic:
		dic[b] += a
	else:
		dic[b] = a
print(max(list(dic.values())))


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def modpow(b, p, m):
	res = 1
	b = b % m
	while p:
		if p & 1:
			res = res * b % m
		b = b * b % m
		p >>= 1
	return res

def mod_inv(a, m):
	return modpow(a, m - 2, m)

def ncr(n, r, m):
	res = 1
	if r == 0:
		return 1
	if n - r < r:
		r = n - r
	(p, k) = (1, 1)
	while r:
		res = res % m * (n % m * mod_inv(r, m) % m) % m
		n -= 1
		r -= 1
	return res

def ncrlis(n, r, m, fact):
	return fact[n] * (mod_inv(fact[r], m) * mod_inv(fact[n - r], m)) % m % m

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = ii()
b = li()
d = dd()
for i in range(n):
	d[b[i] - i] += b[i]
print(max(d.values()))


n = int(input())
beauty_values = list(map(int, input().split()))
combinations = {}
if len(beauty_values) == 1:
	print(beauty_values[0])
	exit()
for i in range(len(beauty_values)):
	difference = beauty_values[i] - i
	if difference not in combinations:
		combinations[difference] = beauty_values[i]
	else:
		combinations[difference] += beauty_values[i]
print(max(combinations.values()))


from collections import Counter
n = int(input())
l = list(map(int, input().split()))
c = Counter()
for i in range(n):
	x = i - l[i]
	c[x] += l[i]
print(max(c.values()))


class node(object):

	def __init__(self):
		self.index = None
		self.b = None
		self.delta = None
n = int(input())
b = input().split()
l = []
for i in range(0, n):
	x = node()
	x.index = i
	x.b = int(b[i])
	x.delta = x.b - x.index
	l.append(x)
l.sort(key=lambda x: x.delta, reverse=True)
j = 0
start = l[0].delta
value = 0
max = 0
while j < n:
	if l[j].delta == start:
		value += l[j].b
	else:
		if value > max:
			max = value
		start = l[j].delta
		value = l[j].b
	if j == n - 1:
		if value > max:
			max = value
	j += 1
print(max)


import math
n = int(input())
ar = list(map(int, input().split()))
freq = {}
for i in range(n):
	if i + 1 - ar[i] in freq:
		freq[i + 1 - ar[i]] += ar[i]
	else:
		freq[i + 1 - ar[i]] = ar[i]
print(max(freq.values()))


n = int(input())
l = list(map(int, input().split(' ')))
m = {}
for i in range(n):
	p = l[i] - (i + 1)
	if p in m:
		m[p].append(l[i])
	else:
		m[p] = [l[i]]
s = 0
for i in m.keys():
	s = max(s, sum(m[i]))
print(s)


n = int(input())
b = list(map(lambda x: int(x), input().split()))
a = [0 for i in range(n)]
for i in range(0, len(a)):
	a[i] = b[i] - i - 1
hashmap = {}
for i in range(0, len(a)):
	if a[i] not in hashmap:
		hashmap[a[i]] = 0
	hashmap[a[i]] += b[i]
print(max(hashmap.items(), key=lambda x: x[1])[1])


x = int(input())
a = list(map(int, input().split()))
b = {}
for i in range(x):
	tem = a[i]
	if tem - i in b.keys():
		b[tem - i] += tem
	else:
		b[tem - i] = tem
ans = -1
for i in b.keys():
	ans = b[i] if ans < b[i] else ans
print(ans)


n = int(input())
lst = list(map(int, input().split()))
dp = {}
for i in range(n):
	dp[lst[i] - i] = dp.get(lst[i] - i, 0) + lst[i]
ans = 0
for key in dp.keys():
	ans = max(dp[key], ans)
print(ans)


import sys
import math
import bisect

def solve(A):
	n = len(A)
	B = [0] * n
	for i in range(n):
		B[i] = A[i] - i
	d = dict()
	for i in range(n):
		if B[i] not in d:
			d[B[i]] = []
		d[B[i]].append(i)
	max_val = 0
	for k in d:
		val = 0
		for a in d[k]:
			val += A[a]
			max_val = max(max_val, val)
	return max_val

def main():
	n = int(input())
	A = list(map(int, input().split()))
	ans = solve(A)
	print(ans)
main()


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
arr = lmp()
ml = [arr[i] - (i + 1) for i in range(n)]
md = dd(int)
for i in range(n):
	md[ml[i]] += arr[i]
print(max(md.values()))


import sys
import math
input = sys.stdin.readline
n = int(input())
b = [int(_) for _ in input().split()]
x = {}
for (i, a) in enumerate(b):
	if a - i in x:
		x[a - i] += a
	else:
		x[a - i] = a
print(max(x.values()))


n = int(input())
mas = list(map(int, input().split()))
b = [0] * n
for i in range(n):
	b[i] = mas[i] - i
d = {}
for i in range(n):
	if str(b[i]) in d:
		d[str(b[i])] += mas[i]
	else:
		d[str(b[i])] = mas[i]
s = list(d.values())
print(max(s))


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
let = '@abcdefghijklmnopqrstuvwxyz'
n = ii()
l = il()
d = dict()
for (i, j) in enumerate(l):
	x = i - j
	if not x in d:
		d[x] = j
	else:
		d[x] += j
print(max((d[i] for i in d)))


d = {}
a = int(input())
z = list(map(int, input().split()))
for i in range(a):
	d[i - z[i]] = d.get(i - z[i], 0) + z[i]
print(max(d.values()))


city_number = int(input())
city_beauty = [int(x) for x in input().split(' ')]
diff_dict = {}
max_beauty = 0
for (i, beauty) in enumerate(city_beauty):
	if diff_dict.get(beauty - i):
		diff_dict[beauty - i] += beauty
	else:
		diff_dict[beauty - i] = beauty
	if diff_dict[beauty - i] > max_beauty:
		max_beauty = diff_dict[beauty - i]
print(max_beauty)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
b = list(map(int, input().split()))
c = []
for i in range(n):
	c.append(b[i] - i)
d = {}
for i in range(n):
	if c[i] in d:
		d[c[i]] += b[i]
	else:
		d[c[i]] = b[i]
print(max(d.values()))


from operator import itemgetter
n = int(input())
bi = list(map(int, input().split()))
ar = [[i - bi[i], bi[i]] for i in range(n)]
ar.sort(key=itemgetter(0))
ans = ar[0][1]
num = ar[0][1]
for i in range(1, n):
	num = num * (ar[i][0] == ar[i - 1][0]) + ar[i][1]
	ans = max(ans, num)
print(ans)


(n, max_beauty, d) = (int(input()), 0, {})
for (index, beauty) in enumerate(input().split()):
	if int(beauty) - index not in d:
		d[int(beauty) - index] = int(beauty)
	else:
		d[int(beauty) - index] += int(beauty)
print(max(d.values()))


n = int(input())
b = list(map(int, input().split()))
c = []
for i in range(n):
	c.append(b[i] - i)
ans = [0] * int(1000000.0)
for i in range(n):
	ans[c[i]] += b[i]
print(sorted(ans)[-1])


import sys
input = sys.stdin.readline
n = int(input())
B = list(map(int, input().split()))
A = []
for i in range(n):
	A.append(B[i] - i)
from collections import Counter
score = Counter()
for i in range(n):
	score[A[i]] += B[i]
print(max(score.values()))


for _ in range(1):
	n = int(input())
	a = [int(i) for i in input().split()]
	ans = {}
	ok = 0
	for i in range(n):
		ans[a[i] - i] = 0
	for i in range(n):
		ans[a[i] - i] += a[i]
	for key in ans:
		ok = max(ok, ans[key])
	print(ok)


import sys
from collections import defaultdict

def main():
	n = int(sys.stdin.readline())
	l = [int(y) for y in sys.stdin.readline().split()]
	d = defaultdict(list)
	for i in range(n):
		x = l[i] - (i + 1)
		d[x].append(l[i])
	ans = []
	for i in d:
		ans.append(sum(d[i]))
	print(max(ans))
main()


n = int(input())
b = list(map(int, input().split()))
c = {}
mx = 0
for i in range(n):
	if c.get(b[i] - i) == None:
		c[b[i] - i] = b[i]
	else:
		c[b[i] - i] += b[i]
	mx = max(mx, c[b[i] - i])
print(mx)


n = int(input())
a = list(map(int, input().split()))
b = [i for i in range(1, n + 1, 1)]
c = []
for (i, j) in zip(a, b):
	c.append([i - j, i])
c = sorted(c)
s = c[0][0]
d = 0
e = []
for i in range(n):
	if s != c[i][0]:
		s = c[i][0]
		e.append(d)
		d = 0
	d += c[i][1]
e.append(d)
print(max(e))


n = int(input())
l1 = list(map(int, input().split()))
l2 = []
for i in range(n):
	l2.append([l1[i] - i, i])
l2.sort()
d = dict()
for i in range(n):
	if l2[i][0] in d.keys():
		d[l2[i][0]] += l1[l2[i][1]]
	else:
		d[l2[i][0]] = l1[l2[i][1]]
a = list(d.values())
print(max(a))