#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 8;
const int T = 2e5 + 2;
int n, b[N], t[N];
template <typename _Tp>
inline void IN(_Tp& x) {
  char ch;
  bool flag = 0;
  x = 0;
  while (ch = getchar(), !isdigit(ch))
    if (ch == '-') flag = 1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  if (flag) x = -x;
}
struct Segment_Tree {
  long long sum[N << 2];
  void update(int x, int l, int r, int pos, int val) {
    if (l == r) {
      sum[x] += val;
      return void();
    }
    (pos <= ((l + r) >> 1))
        ? update(((x) << 1), l, ((l + r) >> 1), pos, val)
        : update(((x) << 1 | 1), ((l + r) >> 1) + 1, r, pos, val);
    sum[x] = max(sum[((x) << 1)], sum[((x) << 1 | 1)]);
  }
} Tree;
int main() {
  IN(n);
  for (int i = 1; i <= n; ++i) IN(b[i]), t[i] = b[i] - i + T;
  for (int i = 1; i <= n; ++i) Tree.update(1, 1, N - 1, t[i], b[i]);
  printf("%lld\n", Tree.sum[1]);
  return 0;
}
