#include <bits/stdc++.h>
using namespace std;
const int N = 250005, mod = 998244353, bit = 61;
struct truck {
  int s, f, c, r;
};
int n, m, a[401], dp[401][401];
vector<truck> adj[401];
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int t = 1;
  while (t--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i <= m; i++) {
      truck b;
      cin >> b.s >> b.f >> b.c >> b.r;
      b.r = min(b.r, b.f - b.s);
      adj[b.s].push_back(b);
    }
    long long ans = 0;
    for (int l = 1; l <= n; l++) {
      for (int r = l; r <= n; r++) {
        dp[r][0] = a[r] - a[l];
      }
      for (int k = 1; k <= n; k++) {
        int opt = l;
        for (int r = l; r <= n; r++) {
          while (opt < r and max(dp[opt][k - 1], a[r] - a[opt]) >=
                                 max(dp[opt + 1][k - 1], a[r] - a[opt + 1])) {
            opt++;
          }
          dp[r][k] = max(dp[opt][k - 1], a[r] - a[opt]);
        }
      }
      for (auto x : adj[l]) {
        ans = max(ans, (long long)x.c * (long long)dp[x.f][x.r]);
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
