#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  int n;
  cin >> n;
  vector<int> b(n);
  for (int &x : b) cin >> x;
  vector<ll> f(n);
  map<ll, ll> m;
  ll ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    f[i] = b[i];
    ll val = b[i] - i;
    if (m.count(val)) {
      f[i] += m[val];
    }
    if (m[b[i] - i] < f[i]) m[b[i] - i] = f[i];
    ans = max(ans, f[i]);
  }
  cout << ans << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int TC = 1;
  for (ll i(1), _i(TC); i <= _i; ++i) {
    solve();
  }
}
