#include <bits/stdc++.h>
#pragma comment(linker, "/stack:512000000")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));
ll const mod = 1e9 + 7;
namespace {
ll mul(ll a, ll b) {
  ll val = a * b - (ll)((ld)a * b / mod) * mod;
  if (val < 0) val += mod;
  if (val >= mod) val -= mod;
  return val;
}
ll poww(ll a, ll b) {
  ll val = 1;
  a %= mod;
  while (b > 0) {
    if (b % 2) val = mul(a, val);
    a = mul(a, a);
    b >>= 1;
  }
  return val % mod;
}
ll inv(ll a) { return poww(a, mod - 2); }
}  // namespace
ll const maxn = 5e5 + 5;
ll last[maxn];
ll dp[maxn];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<ll> b(n + 1);
  for (ll i = 1; i <= n; i++) {
    b[i] = a[i] - i;
  }
  for (ll i = 1; i <= n; i++) {
    dp[i] = max(dp[i], a[i]);
    if (last[b[i]]) {
      dp[i] = max(dp[i], dp[last[b[i]]] + a[i]);
    }
    last[b[i]] = i;
  }
  cout << *max_element(dp, dp + n + 1) << endl;
  return 0;
}
