#include <bits/stdc++.h>
using namespace std;
int countbit(int a) {
  int c = 0;
  while (a) {
    if (a & 1) c++;
    a >>= 1;
  }
  return (c);
}
int sum(vector<int> &st, int l, int r, int x, int y, int pos) {
  int ans = 0;
  int mid = l + (r - l) / 2;
  if (x <= l && y >= r)
    return (st[pos]);
  else if (y < l || r < x)
    return (0);
  return (sum(st, l, mid, x, y, 2 * pos + 1) |
          sum(st, mid + 1, r, x, y, 2 * pos + 2));
}
void segment_tree(vector<int> &st, int r, int l, int pos, char val, int i) {
  if (r == l) {
    st[pos] = 0;
    st[pos] = (1 << (val - 'a'));
  } else {
    int mid = r + (l - r) / 2;
    if (r <= i && mid >= i) segment_tree(st, r, mid, 2 * pos + 1, val, i);
    if (mid + 1 <= i && l >= i)
      segment_tree(st, mid + 1, l, 2 * pos + 2, val, i);
    st[pos] = 0;
    st[pos] = st[2 * pos + 1] | st[2 * pos + 2];
  }
}
long long rem(string s, int in) {
  long long ans = 0, i = 0;
  for (i = 0; i < s.size(); ++i) {
    if (i == in) continue;
    ans *= 10;
    ans += (s[i] - '0');
  }
  return (ans);
}
bool check(string s, string t) {
  std::vector<int> v(36);
  for (int i = 0; i < s.length(); ++i) {
    v[s[i] - 'a']++;
  }
  for (int i = 0; i < t.length(); ++i) {
    v[t[i] - 'a']--;
  }
  for (int i = 0; i < 36; ++i) {
    if (v[i] != 0) return (0);
  }
  return (1);
}
long long power(long long a, long long p, long long m = 1000000007) {
  a %= m;
  long long val = 1;
  while (p > 0) {
    if (p & 1) {
      val = (val * a) % m;
    }
    a = (a * a) % m;
    p >>= 1;
  }
  return (val);
}
inline int comp(int ec, long long a, int hc, long long b, long long t2) {
  int ans = 0;
  int ac = min(t2 / a, (long long)ec);
  t2 -= ac * a;
  int bc = min(t2 / b, (long long)hc);
  return (bc + ac);
}
std::vector<pair<long long, int>> primeFactors(long long n) {
  std::vector<pair<long long, int>> v;
  long long c = 0, f = 1, k, i;
  k = n;
  while ((!(n & 1)) && n > 1) {
    n = n / 2;
    c++;
  }
  if (c) {
    v.push_back({2, c});
  }
  for (i = 3; n > 1 && i <= n; ++i) {
    c = 0;
    while (n % i == 0 && n > 1) {
      n /= i;
      c++;
    }
    if (c) {
      v.push_back({i, c});
    }
    if (c == 0 && i * i >= n) {
      v.push_back({n, 1});
      break;
    }
  }
  if (k == n && k != 1) {
    std::vector<pair<long long, int>> v2;
    v2.push_back({k, 1});
    return v2;
  }
  return v;
}
int rec(std::vector<int> &v, int bit) {
  if (v.size() == 0 || bit < 0) return 0;
  std::vector<int> l, r;
  for (int i = 0; i < v.size(); ++i) {
    if ((v[i] >> bit) & 1)
      l.push_back(v[i]);
    else
      r.push_back(v[i]);
  }
  if (l.size() == 0) return (rec(r, bit - 1));
  if (r.size() == 0) return (rec(l, bit - 1));
  return ((1 << bit) + min(rec(r, bit - 1), rec(l, bit - 1)));
}
string rev(string a) {
  string s = "";
  for (int i = a.length() - 1; i >= 0; --i) {
    s = s + a[i];
  }
  return (s);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, j;
  int T = 1;
  while (T--) {
    int n;
    cin >> n;
    std::vector<int> b(n);
    for (i = 0; i < n; ++i) {
      cin >> b[i];
    }
    map<int, long long> m;
    long long ans = 0;
    for (i = n - 1; i >= 0; --i) {
      int p = b[i] - i - 1;
      auto it = m.find(p);
      if (it == m.end()) {
        m[p] = b[i];
        ans = max(ans, 1ll * b[i]);
      } else {
        ans = max(ans, it->second + b[i]);
        m[p] = it->second + b[i];
      }
    }
    cout << ans << "\n";
  }
}
