#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
long long f[N << 1], b[N << 1], a[N << 1];
int main() {
  int n = read();
  long long ans = 0;
  for (int i = 1; i <= n; ++i) {
    int x = read();
    f[i] = max(f[i], a[x - i + N] + x);
    a[x - i + N] = max(a[x - i + N], f[i]);
    ans = max(ans, f[i]);
  }
  cout << ans;
  return 0;
}
