#include <bits/stdc++.h>
using namespace std;
int n;
long long dp[200005];
int a[200005];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  long long maxx = 0;
  map<int, int> my;
  for (int i = n; i >= 1; i--) {
    int x = a[i];
    if (my[x - i] != 0) {
      dp[i] = dp[my[x - i]];
    } else
      dp[i] = 0;
    dp[i] += x;
    maxx = max(maxx, dp[i]);
    my[x - i] = i;
  }
  cout << maxx << endl;
  return 0;
}
