#include <bits/stdc++.h>
using namespace std;
const int maxn = 407;
const int maxb = 29;
const long long ool = 1e18 + 7;
class car {
 public:
  long long s;
  long long t;
  long long r;
  long long c;
  car(long long ss = 1, long long tt = 1, long long cc = 1, long long rr = 1) {
    s = ss;
    t = tt;
    r = rr;
    c = cc;
  }
};
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<long long> pos(n + 1);
  vector<vector<vector<long long> > > dp(
      2, vector<vector<long long> >(n + 1, vector<long long>(n + 1)));
  vector<vector<car> > ck(n + 1);
  for (int i = (1); i <= (n); ++i) cin >> pos[i];
  for (int i = (0); i < (m); ++i) {
    int s, t, r, c;
    cin >> s >> t >> c >> r;
    int kk = min(t - s - 1, r) + 1;
    ck[kk].emplace_back(car(s, t, c, kk));
  }
  int t = 0;
  long long ans = 0;
  for (int i = (1); i <= (n); ++i)
    for (int j = (i); j <= (n); ++j)
      dp[t][i][j] = (i == j ? 0 : pos[j] - pos[i]);
  for (int k = (1); k < (n); ++k) {
    for (auto x : ck[k]) ans = max(dp[t][x.s][x.t] * x.c, ans);
    if (k == n - 1) break;
    for (int i = (1); i <= (n); ++i)
      for (int j = (i); j <= (n); ++j) dp[t ^ 1][i][j] = ool;
    for (int i = (1); i <= (n); ++i) {
      dp[t ^ 1][i][i] = 0;
      int x = i;
      for (int j = (i + 1); j <= (n); ++j) {
        while (dp[t][i][x] < pos[j] - pos[x]) x++;
        dp[t ^ 1][i][j] = min(dp[t][i][x], pos[j] - pos[x - 1]);
      }
    }
    t ^= 1;
  }
  cout << ans << endl;
  return 0;
}
