#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
int n;
long long dp[500500];
map<long long, long long> mx;
long long a[500500], c[500500];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i], c[i] = a[i] - i;
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    dp[i] = mx[c[i]] + a[i];
    mx[c[i]] = max(mx[c[i]], dp[i]);
    ans = max(ans, dp[i]);
  }
  cout << ans << "\n";
  return 0;
}
