#include <bits/stdc++.h>
using namespace std;
struct node {
  int j, k;
  long long c;
};
constexpr int M = 3 * 1e5, N = 435;
constexpr long long INF = 1000000000000000000ll;
int n, m, big[N][N], cut[N][N];
long long dp[N][N], d[N], res;
vector<node> v[N];
inline node make_node(int a, int b, long long _c) {
  node ret;
  ret.j = a;
  ret.k = b;
  ret.c = _c;
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> d[i], big[i - 1][i] = d[i] - d[i - 1];
  for (int i = 0; i < m; i++) {
    int s, f, c, r;
    cin >> s >> f >> c >> r;
    v[s].push_back(make_node(f, r, c));
  }
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      big[i][j] = big[j][i] = max(d[j] - d[j - 1], (long long)big[i][j - 1]);
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        dp[j][k] = INF;
        cut[j][k] = -1;
      }
      dp[j][0] = d[j] - d[i];
      cut[j][0] = 0;
    }
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k <= n; k++) {
        dp[j][k] = 0;
      }
    }
    for (int i = 0; i <= n; i++) {
      cut[n + 1][i] = n + 1;
    }
    for (int len = 1; len <= n - i; len++) {
      for (int j = n; j >= i; j--) {
        dp[j][len] = dp[j][len - 1];
        cut[j][len] = cut[j][len - 1];
        for (int k = max(cut[j][len - 1], i); k <= min(cut[j + 1][len], j);
             k++) {
          if (dp[j][len] > max(dp[k][len - 1], d[j] - d[k])) {
            cut[j][len] = k;
            dp[j][len] = max(dp[k][len - 1], d[j] - d[k]);
          }
        }
      }
    }
    for (node nn : v[i]) {
      res = max(res, nn.c * dp[nn.j][min(nn.j - i - 1, nn.k)]);
    }
  }
  cout << res << '\n';
}
