#include <bits/stdc++.h>
using namespace std;
struct data {
  long long x;
} t[int(1e6 + 5) << 2];
int N;
long long ma, f[int(1e6 + 5)];
inline void read(int &x) {
  x = 0;
  bool f = 0;
  char ch = getchar();
  for (; !(ch >= '0' && ch <= '9'); ch = getchar()) f |= ch == '-';
  for (; (ch >= '0' && ch <= '9'); ch = getchar())
    x = (x << 3) + (x << 1) + (ch ^ 48);
  x = f ? -x : x;
}
inline void update(int ro, int L, int R, int x, long long val) {
  if (L == R) {
    t[ro].x = ((val) > (t[ro].x) ? (val) : (t[ro].x));
    return;
  }
  int Mid = (L + R) >> 1;
  if (x <= Mid)
    update(ro << 1, L, Mid, x, val);
  else
    update(ro << 1 | 1, Mid + 1, R, x, val);
}
inline long long query(int ro, int L, int R, int x) {
  if (L == R) return t[ro].x;
  int Mid = (L + R) >> 1;
  if (x <= Mid)
    return query(ro << 1, L, Mid, x);
  else
    return query(ro << 1 | 1, Mid + 1, R, x);
}
int main() {
  read(N);
  for (int i = 1; i <= N; ++i) {
    int x, y;
    read(x);
    y = x - i;
    f[i] = query(1, 1, int(1e6 + 5) * 2, y + int(1e6 + 5)) + x;
    update(1, 1, int(1e6 + 5) * 2, y + int(1e6 + 5), f[i]);
  }
  for (int i = 1; i <= N; ++i) ma = ((ma) > (f[i]) ? (ma) : (f[i]));
  cout << ma << endl;
  return 0;
}
