#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
const long double pi = acos(-1.0);
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while ((ch < '0') || (ch > '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ((ch >= '0') && (ch <= '9')) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return x * f;
}
namespace My_Math {
int fac[100000 + 100], invfac[100000 + 100];
int add(int x, int y) { return x + y >= 998244353 ? x + y - 998244353 : x + y; }
int dec(int x, int y) { return x < y ? x - y + 998244353 : x - y; }
int mul(int x, int y) { return 1ll * x * y % 998244353; }
long long qpow(long long x, int y) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = mul(ans, x);
    x = mul(x, x);
    y >>= 1;
  }
  return ans;
}
int inv(int x) { return qpow(x, 998244353 - 2); }
int C(int n, int m) {
  if ((n < m) || (n < 0) || (m < 0)) return 0;
  return mul(mul(fac[n], invfac[m]), invfac[n - m]);
}
int math_init() {
  fac[0] = invfac[0] = 1;
  for (register int i = 1; i <= 100000; i++) fac[i] = mul(fac[i - 1], i);
  invfac[100000] = inv(fac[100000]);
  for (register int i = 100000 - 1; i >= 1; i--)
    invfac[i] = mul(invfac[i + 1], i + 1);
}
}  // namespace My_Math
using namespace My_Math;
const int bas = 1000000;
int n, a[bas * 4], b[bas * 4];
long long f[600600];
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) a[i] = read();
  for (register int i = 1; i <= n; i++) {
    int now = i - a[i] + bas;
    f[i] = f[b[now]] + a[i];
    b[now] = i;
  }
  long long ans = 0;
  for (register int i = 1; i <= n; i++) ans = max(ans, f[i]);
  cout << ans;
  return 0;
}
