#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1, c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return f == 1 ? x : -x;
}
const long long N = 2e5 + 4;
long long n, ans, a[N], f[N];
map<long long, long long> mp;
signed main() {
  n = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= n; i++) {
    f[i] = mp[i - a[i]] + a[i];
    mp[i - a[i]] = f[i];
    ans = max(ans, f[i]);
  }
  cout << ans << "\n";
  return (0 - 0);
}
